Skip to content

Commit

Permalink
State change in patroni 3.0.4
Browse files Browse the repository at this point in the history
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
  • Loading branch information
blogh committed Aug 18, 2023
1 parent e9f197b commit 8f59c90
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions check_patroni/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion check_patroni/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ def probe(self: "ClusterHasReplica") -> Iterable[nagiosplugin.Metric]:
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"
):
replicas.append({"name": member["name"], "lag": member["lag"]})
if self.max_lag is None or self.max_lag >= int(member["lag"]):
healthy_replica += 1
Expand Down

0 comments on commit 8f59c90

Please sign in to comment.