diff --git a/pyproject.toml b/pyproject.toml index 114e64c..a807648 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ requires-python = ">= 3.8" dynamic = ["version"] dependencies = [ "salt>=3006", + "kazoo", ] [project.readme] diff --git a/src/saltext/zookeeper/modules/zk_concurrency.py b/src/saltext/zookeeper/modules/zk_concurrency.py index 14eba7f..7f11e7c 100644 --- a/src/saltext/zookeeper/modules/zk_concurrency.py +++ b/src/saltext/zookeeper/modules/zk_concurrency.py @@ -46,7 +46,7 @@ def __init__( try: for child in self.client.get_children(self.path): try: - data, stat = self.client.get(self.path + "/" + child) + data, _ = self.client.get(self.path + "/" + child) if identifier == data.decode("utf-8"): self.create_path = self.path + "/" + child self.is_acquired = True @@ -150,7 +150,7 @@ def lock_holders( zk_hosts=None, identifier=None, max_concurrency=1, - timeout=None, + timeout=None, # pylint: disable=unused-argument ephemeral_lease=False, profile=None, scheme=None, @@ -161,6 +161,12 @@ def lock_holders( """ Return an un-ordered list of lock holders + CLI Example: + + .. code-block:: bash + + salt '*' zk_concurrency.lock_holders some/path + path The path in zookeeper where the lock is @@ -221,6 +227,12 @@ def lock( """ Get lock (with optional timeout) + CLI Example: + + .. code-block:: bash + + salt '*' zk_concurrency.lock some/path + path The path in zookeeper where the lock is @@ -296,6 +308,12 @@ def unlock( """ Remove lease from semaphore + CLI Example: + + .. code-block:: bash + + salt '*' zk_concurrency.unlock some/path + path The path in zookeeper where the lock is @@ -363,6 +381,12 @@ def party_members( Get the List of identifiers in a particular party, optionally waiting for the specified minimum number of nodes (min_nodes) to appear + CLI Example: + + .. code-block:: bash + + salt '*' zk_concurrency.party_members some/path + path The path in zookeeper where the lock is diff --git a/src/saltext/zookeeper/states/zk_concurrency.py b/src/saltext/zookeeper/states/zk_concurrency.py index 8b927cc..9ed3c82 100644 --- a/src/saltext/zookeeper/states/zk_concurrency.py +++ b/src/saltext/zookeeper/states/zk_concurrency.py @@ -194,7 +194,9 @@ def min_party( name, zk_hosts, min_nodes, blocking=blocking, **conn_kwargs ) if not isinstance(nodes, list): - raise Exception(f"Error from zk_concurrency.party_members, return was not a list: {nodes}") + ret["result"] = False + ret["comment"] = f"Error from zk_concurrency.party_members, return was not a list: {nodes}" + return ret num_nodes = len(nodes) diff --git a/tests/functional/states/test_zookeeper.py b/tests/functional/states/test_zookeeper.py index 77a50cc..fa6a389 100644 --- a/tests/functional/states/test_zookeeper.py +++ b/tests/functional/states/test_zookeeper.py @@ -7,15 +7,12 @@ import pytest from saltfactories.utils import random_string -pytest.importorskip("kazoo") pytest.importorskip("docker") log = logging.getLogger(__name__) pytestmark = [ - pytest.mark.slow_test, - pytest.mark.skip_if_binaries_missing("dockerd"), - pytest.mark.slow_test, + pytest.mark.skip_if_binaries_missing("docker", "dockerd", check_all=False), ] @@ -60,7 +57,7 @@ def minion_config_overrides(zookeeper_port): def zookeeper_container(salt_factories): container = salt_factories.get_container( random_string("zookeeper-"), - "ghcr.io/saltstack/salt-ci-containers/zookeeper", + "docker.io/library/zookeeper", container_run_kwargs={ "ports": { "2181/tcp": None, diff --git a/tests/unit/states/test_zk_concurrency.py b/tests/unit/states/test_zk_concurrency.py index 7f979c1..63eeb7f 100644 --- a/tests/unit/states/test_zk_concurrency.py +++ b/tests/unit/states/test_zk_concurrency.py @@ -7,7 +7,7 @@ import pytest -import saltext.zookeeper.states.zk_concurrency as zk_concurrency +from saltext.zookeeper.states import zk_concurrency @pytest.fixture