From a01a535680cb88bc1851df8f9f45d5bde19473eb Mon Sep 17 00:00:00 2001 From: benoit Date: Mon, 21 Aug 2023 13:07:20 +0200 Subject: [PATCH] Add sync_standby as an acceptable state for a replica --- README.md | 2 +- check_patroni/cli.py | 2 +- check_patroni/cluster.py | 2 +- tests/json/cluster_has_replica_ok.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 17aaf00..a373fb2 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ Usage: check_patroni cluster_has_replica [OPTIONS] A healthy replica: * is in running or streaming state (V3.0.4) - * has a replica role + * has a replica or sync_standby role * has a lag lower or equal to max_lag Check: diff --git a/check_patroni/cli.py b/check_patroni/cli.py index f7e0cae..db3b6d9 100644 --- a/check_patroni/cli.py +++ b/check_patroni/cli.py @@ -324,7 +324,7 @@ def cluster_has_replica( \b A healthy replica: * is in running or streaming state (V3.0.4) - * has a replica role + * has a replica or sync_standby role * has a lag lower or equal to max_lag \b diff --git a/check_patroni/cluster.py b/check_patroni/cluster.py index 55e9bdc..26fa4d8 100644 --- a/check_patroni/cluster.py +++ b/check_patroni/cluster.py @@ -91,7 +91,7 @@ class ClusterHasReplica(PatroniResource): unhealthy_replica = 0 for member in item_dict["members"]: # FIXME are there other acceptable states - if member["role"] == "replica": + if member["role"] in ["replica", "sync_standby"]: # patroni 3.0.4 changed the standby state from running to streaming if ( member["state"] in ["running", "streaming"] diff --git a/tests/json/cluster_has_replica_ok.json b/tests/json/cluster_has_replica_ok.json index 547d6c8..a74fcd2 100644 --- a/tests/json/cluster_has_replica_ok.json +++ b/tests/json/cluster_has_replica_ok.json @@ -21,7 +21,7 @@ }, { "name": "srv3", - "role": "replica", + "role": "sync_standby", "state": "running", "api_url": "https://10.20.199.5:8008/patroni", "host": "10.20.199.5",