Commit graph

16 commits

Author SHA1 Message Date
benoit 8d6b8502b6 cluster_has_replica: fix the way a healthy replica is detected
For patroni >= version 3.0.4:
* the role is `replica` or `sync_standby`
* the state is `streaming` or `in archive recovery`
* the timeline is the same as the leader
* the lag is lower or equal to `max_lag`

For prio versions of patroni:
* the role is `replica` or `sync_standby`
* the state is `running`
* the timeline is the same as the leader
* the lag is lower or equal to `max_lag`

Additionnally, we now display the timeline in the perfstats. We also try
to display the perf stats of unhealthy replica as much as possible.

Update tests for cluster_has_replica:
* Fix the tests to make them work with the new algotithm
* Add a specific test for tl divergences
2023-11-11 10:50:35 +01:00
Denis Laxalde 6ee8db1df2 Avoid using requests's JSONDecodeError
This exception is only present in "recent" version of requests,
typically not in the version distributed by Debian bullseye. Since
requests' JSONDecodeError is in general a subclass of
json.JSONDecodeError, we use the latter, but also handle the plain
ValueError (which json.JSONDecodeError is a subclass of) because
requests might use simplejson (which uses its own JSONDecodeError, also
a subclass of ValueError).
2023-10-13 11:45:39 +02:00
Denis Laxalde 95f21a133d Drop superfluous type annotation of 'self'
See https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html#classes
> For instance methods, omit type for "self"
2023-10-03 09:39:40 +02:00
benoit b69c2501fd Revert commit 20d9d48
For `node_is_alive`, it seemed to be a good idea to exit with a
`CRITICAL` when the target doesn't exist. But for all the rest, UNKNOWN
(which corresponds to a configuration error) seems better.
2023-08-23 18:35:06 +02:00
benoit 20d9d48d78 Fix the liveness check in node_is_alive
Previously if a node wasn't reachable whe would get an UNKNOWN error.
instead of a CRITICAL error.

```
NODEISALIVE UNKNOWN - Connection failed for all provided endpoints
```

We now get the correct error.

```
NODEISALIVE CRITICAL - This node is not alive (patroni is not running). | is_alive=0;;@0
```
2023-08-23 16:05:02 +02:00
benoit d07a26d324 Fix tests in a more pytonic way as proposed by @dlax 2023-08-21 15:13:22 +02:00
benoit 77722f40c1 Fix liveness check
The liveness probe used to return something. It looks like it doesn't do
it anymore and it breaks the `node_is_alive` check.

Issue: #31
2023-08-21 15:13:22 +02:00
benoit df744bf7dc Use isort to automatically sort imports 2023-03-20 14:56:11 +01:00
benoit dff95eae2f Fixing logging issues in the previous modifications 2023-03-20 12:25:32 +01:00
benoit 7eea4c94be Reorganise for the urllib3 > requests change 2023-03-20 12:25:32 +01:00
benoit 2443505ad6 Change logging
We now use our own logger.
When debug is set (-vvv), we also display urllib3's debug info.
2023-03-20 12:25:32 +01:00
benoit 9cd80f5af8 Move from urllib3 to requests 2023-03-20 12:25:32 +01:00
benoit aa1de928d3 An attempt at correctly ordering imports 2022-02-07 15:11:05 +01:00
benoit 6c696a03ee Mypy fix
Stop using ctx.parent.params to get the verbose and timeout parameters
parsed in main and use ctx.obj instead.

ctx.parent.params is typed as Optional[Context] which forces us to test
if it's NULL before using it. It's useless in our case because we know
it's not empty and the resulting code is ugly.

The mypy ierror.

Item "None" of "Optional[Context]" has an attribute "params"
[union-attr]
2021-09-11 00:36:57 +02:00
benoit db3f008b81 More Typing 2021-08-12 13:07:28 +02:00
benoit 1e6adc6a1a First working version 2021-08-12 13:07:10 +02:00