Repository navigation
feat(instance): liveness probe isolation checker - #7466
Conversation
|
❗ By default, the pull request is configured to backport to all release branches.
|
|
I built the operator with this patch on my laptop and followed Nikolay's instructions in #7407. I was able to see that the isolated primary shut down due to the liveness probe failing. Below I detail the whole process so that anyone can easily reproduce and test it. The PoC can be considered successful and I believe we should proceed in the liveness probe direction. This is a very elegant, clean, linear and robust implementation. Most importantly, it resonates with Kubernetes HA principles to delegate to the actual workload the responsibility to kill themselves when isolated. The next step is to refine the logs and the code, define the UI and the default values, and provide tests. Crazy idea: if we see that this patch gets consensus before RC3, we could even consider introducing a feature-flag annotation in 1.26 to help us experiment with this for 1.27. Thoughts? Reproducible caseI checked out this PR code and followed the instructions here: https://github.com/cloudnative-pg/cloudnative-pg/tree/main/contribute/development_environment#building-the-operator-and-deploying-it-locally I created the following apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cnpg
spec:
instances: 3
storage:
size: 1GiI observed the primary ( I connected via docker to the docker exec -ti pg-operator-e2e-v1-33-0-worker2 bashOnce inside, I got the ID of the container that was running crictl psMade sure that this is a primary: crictl exec $CONTAINER_ID pg_controldataThen started streaming the logs of the container: crictl logs -f $CONTAINER_IDThen disconnected the network with: docker network disconnect kind pg-operator-e2e-v1-33-0-worker2The liveness probe started to fail: The pod is correctly shut down when the liveness probe is declared failed. The pod is restarted but Postgres never starts as the API server cannot be reached. Running |
0027a7c to
02bdd21
Compare
|
/test limit=local |
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/14837844128 |
641565b to
5f1050b
Compare
Enhances the liveness probe logic for primary instances in HA clusters to detect network isolation scenarios. The probe first checks if the Pod can reach the API server. If the API server is unreachable, it then attempts to contact peer PostgreSQL instances in the same cluster via a REST entrypoint. If neither the API server nor any replicas are reachable, the liveness probe fails, prompting Kubernetes to restart the Pod. Upon restart, the instance manager will refuse to start PostgreSQL, as it cannot download the Cluster definition—preventing unsafe behavior in isolated environments. This behavior applies only to primary instances in clusters with HA replicas. Closes: cloudnative-pg#7465 Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Niccolò Fei <[email protected]>
Signed-off-by: Niccolò Fei <[email protected]>
Signed-off-by: Niccolò Fei <[email protected]>
In kindest/node 1.27 & 1.28, the version of crictl installed doesn't support the `--namespace flag`. Use label selectors instead. Signed-off-by: Niccolò Fei <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
|
/test |
|
@leonardoce, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/14976919030 |
Signed-off-by: Marco Nenciarini <[email protected]>
Enhances the liveness probe logic for primary instances in HA clusters to detect network isolation scenarios.
The probe first checks if the Pod can reach the API server. If the API server is unreachable, it then attempts to contact peer PostgreSQL instances in the same cluster via a REST entrypoint.
If neither the API server nor any replicas are reachable, the liveness probe fails, prompting Kubernetes to restart the Pod.
Upon restart, the instance manager will refuse to start PostgreSQL, as it cannot download the Cluster definition—preventing unsafe behavior in isolated environments.
This behavior applies only to primary instances in clusters with HA replicas.
Closes: #7465