diff options
author | Pavlo Shchelokovskyy <shchelokovskyy@gmail.com> | 2022-02-02 15:06:27 +0200 |
---|---|---|
committer | Alan Bishop <abishop@redhat.com> | 2022-08-24 08:12:17 -0700 |
commit | b64623daeb9e0f94fd5322a1c7e47403f187e7ed (patch) | |
tree | bce759f97f70ae9a4fe6d224953ddb7093656a49 | |
parent | e88e601f925677d3faeadc6851dd28a0b8ec630f (diff) | |
download | tooz-b64623daeb9e0f94fd5322a1c7e47403f187e7ed.tar.gz |
Support etcd3gw api version
since etcd3 3.5 dropped support for v3alpha and v3beta api, replacing
those with v3.
etcd3gw library supports passing api_path (v3alpha by default), but tooz
lacks such possibility and thus can not work with etcd3 3.5.
This patch adds handling of "api_version" in the options to
"ectd3+https" connection URLs (defaults to v3alpha as it is today and
corresponds to etcd3 version shipped in major LTS distros at the
moment).
Closes-Bug: #1983668
Depends-On: I49c480f573a4ba8294627a3ce730b816ded10aed
Change-Id: Ib30c1e003f261cd7e1ac6fed87167f9974bf8542
-rw-r--r-- | tooz/drivers/etcd3gw.py | 6 | ||||
-rw-r--r-- | tooz/tests/drivers/test_etcd3gw.py | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/tooz/drivers/etcd3gw.py b/tooz/drivers/etcd3gw.py index 232b3ae..97af3ed 100644 --- a/tooz/drivers/etcd3gw.py +++ b/tooz/drivers/etcd3gw.py @@ -177,6 +177,7 @@ class Etcd3Driver(coordination.CoordinationDriverWithExecutor): ================== ======= Name Default ================== ======= + api_version v3alpha ca_cert None cert_key None cert_cert None @@ -195,6 +196,9 @@ class Etcd3Driver(coordination.CoordinationDriverWithExecutor): #: Default port used if none provided (4001 or 2379 are the common ones). DEFAULT_PORT = 2379 + #: Default api version if none provided + DEFAULT_API_VERSION = "v3alpha" + GROUP_PREFIX = b"tooz/groups/" def __init__(self, member_id, parsed_url, options): @@ -207,12 +211,14 @@ class Etcd3Driver(coordination.CoordinationDriverWithExecutor): cert_key = options.get('cert_key') cert_cert = options.get('cert_cert') timeout = int(options.get('timeout', self.DEFAULT_TIMEOUT)) + api_version = options.get("api_version", self.DEFAULT_API_VERSION) self.client = etcd3gw.client(host=host, port=port, protocol=protocol, ca_cert=ca_cert, cert_key=cert_key, cert_cert=cert_cert, + api_path="/" + api_version + "/", timeout=timeout) self.lock_timeout = int(options.get('lock_timeout', timeout)) self.membership_timeout = int(options.get( diff --git a/tooz/tests/drivers/test_etcd3gw.py b/tooz/tests/drivers/test_etcd3gw.py index a182b77..3b8a09c 100644 --- a/tooz/tests/drivers/test_etcd3gw.py +++ b/tooz/tests/drivers/test_etcd3gw.py @@ -34,16 +34,19 @@ class TestEtcd3Gw(testcase.TestCase): 'ca_cert': None, 'cert_key': None, 'cert_cert': None, + 'api_path': ( + "/" + etcd3gw_driver.Etcd3Driver.DEFAULT_API_VERSION + "/"), 'timeout': etcd3gw_driver.Etcd3Driver.DEFAULT_TIMEOUT}, {'coord_url': ('etcd3+https://my_host:666?ca_cert=/my/ca_cert&' 'cert_key=/my/cert_key&cert_cert=/my/cert_cert&' - 'timeout=42'), + 'timeout=42&api_version=v3'), 'protocol': 'https', 'host': 'my_host', 'port': 666, 'ca_cert': '/my/ca_cert', 'cert_key': '/my/cert_key', 'cert_cert': '/my/cert_cert', + 'api_path': '/v3/', 'timeout': 42}) @ddt.unpack @mock.patch('etcd3gw.client') @@ -56,6 +59,7 @@ class TestEtcd3Gw(testcase.TestCase): ca_cert, cert_key, cert_cert, + api_path, timeout): tooz.coordination.get_coordinator(coord_url, self.FAKE_MEMBER_ID) mock_etcd3gw_client.assert_called_with(host=host, @@ -64,4 +68,5 @@ class TestEtcd3Gw(testcase.TestCase): ca_cert=ca_cert, cert_key=cert_key, cert_cert=cert_cert, + api_path=api_path, timeout=timeout) |