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
This commit is contained in:
benoit 2023-08-18 18:12:05 +02:00 committed by Benoit
parent e9f197b9d9
commit 2f250e846e
3 changed files with 9 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -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