From 2f250e846e3271dbec13bff3dcb8e92bca9507fd Mon Sep 17 00:00:00 2001 From: benoit Date: Fri, 18 Aug 2023 18:12:05 +0200 Subject: [PATCH] State change in patroni 3.0.4 Since patroni 3.0.4, standby node nominal state is "streaming" instead of "running". Some services need to be changed to account for that. Reported in issue #28 --- README.md | 4 ++-- check_patroni/cli.py | 4 ++-- check_patroni/cluster.py | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9693273..de6d94c 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,7 @@ Usage: check_patroni cluster_has_replica [OPTIONS] Check if the cluster has healthy replicas. A healthy replica: - * is in running state + * is in running or streaming state (V3.0.4) * has a replica role * has a lag lower or equal to max_lag @@ -216,7 +216,7 @@ Usage: check_patroni cluster_node_count [OPTIONS] * running custom bootstrap script, custom bootstrap failed * starting, start failed * restarting, restart failed - * running + * running, streaming (for a replica V3.0.4) * stopping, stopped, stop failed * creating replica * crashed diff --git a/check_patroni/cli.py b/check_patroni/cli.py index 30c70ca..52b4989 100644 --- a/check_patroni/cli.py +++ b/check_patroni/cli.py @@ -229,7 +229,7 @@ def cluster_node_count( * running custom bootstrap script, custom bootstrap failed * starting, start failed * restarting, restart failed - * running + * running, streaming (for a replica V3.0.4) * stopping, stopped, stop failed * creating replica * crashed @@ -322,7 +322,7 @@ def cluster_has_replica( \b A healthy replica: - * is in running state + * is in running or streaming state (V3.0.4) * has a replica role * has a lag lower or equal to max_lag diff --git a/check_patroni/cluster.py b/check_patroni/cluster.py index 62026cf..b5c1d63 100644 --- a/check_patroni/cluster.py +++ b/check_patroni/cluster.py @@ -90,7 +90,11 @@ class ClusterHasReplica(PatroniResource): for member in item_dict["members"]: # FIXME are there other acceptable states if member["role"] == "replica": - if member["state"] == "running" and member["lag"] != "unknown": + # patroni 3.0.4 changed the standby state from running to streaming + if ( + member["state"] in ["running", "streaming"] + and member["lag"] != "unknown" # noqa: W503 + ): replicas.append({"name": member["name"], "lag": member["lag"]}) if self.max_lag is None or self.max_lag >= int(member["lag"]): healthy_replica += 1