Skip to content

[18.0-fr6] Fix galera bootstrap deadlock when all pods are killed simultaneously#500

Merged
openshift-merge-bot[bot] merged 1 commit into
openstack-k8s-operators:18.0-fr6from
openshift-cherrypick-robot:cherry-pick-499-to-18.0-fr6
Jul 7, 2026
Merged

[18.0-fr6] Fix galera bootstrap deadlock when all pods are killed simultaneously#500
openshift-merge-bot[bot] merged 1 commit into
openstack-k8s-operators:18.0-fr6from
openshift-cherrypick-robot:cherry-pick-499-to-18.0-fr6

Conversation

@openshift-cherrypick-robot

Copy link
Copy Markdown

This is an automated cherry-pick of #499

/assign dciabrin

Three issues combined to delay galera cluster recovery by 12-54+
minutes when all pods were killed at once.

1. Status update race: injectGcommURI() stored gcomm state in
   Status.Attributes. The deferred PatchInstance (JSON merge patch)
   wrote this back, overwriting pod-pushed attributes (including
   ContainerIDs) with stale data from the start of the reconcile.

   Fix: stop writing gcomm state to Status.Attributes entirely.
   GaleraAttributes is now read-only from the operator's perspective.
   Bootstrap-in-progress state is tracked via a sync.Map on the
   reconciler, keyed by the Galera CR's NamespacedName, storing
   only the bootstrap pod name and its containerID at injection time.
   Joiner injection is not tracked at all — the filesystem check in
   isGaleraContainerStartedAndWaiting (test ! -f gcomm_uri && pgrep
   detect_gcomm_and_start.sh) already prevents double-injection,
   since the detect script exec's into mysqld after consuming the file.

   On operator restart, reconstructBootstrapState probes Running pods
   for a mysqld process (pgrep -aP1) to detect a bootstrap already
   in progress, avoiding spurious re-injection of gcomm:// files.

2. Unnecessary ContainerID check in findBestCandidate(): the function
   required all replicas to have attributes with ContainerIDs matching
   the currently running containers. But pods restart faster than the
   reconcile cycle, so CIDs never match. This check is unnecessary
   during bootstrap recovery because no pod has started mysqld (pods
   are blocked waiting for gcomm_uri), so the seqno on the persistent
   volume cannot change between container restarts.

   Fix: remove the CID comparison from findBestCandidate(). Only
   require that all replicas have pushed attributes with valid seqnos.
   Log CID mismatches for observability without blocking the decision.

3. Spurious joiner push: when all pods were killed, the StatefulSet's
   AvailableReplicas could remain > 0 briefly (stale due to the
   startup probe timeout, 240s by default), causing Bootstrapped to
   be true. The operator pushed joiner gcomm URIs to pods, making
   them start mysqld against dead peers and wasting a restart cycle.

   Fix: skip joiner gcomm push when Bootstrapped is set but no pods
   are actually Ready.

Also add a periodic 10s requeue when not bootstrapped, ensuring the
reconciler retries even when no external events trigger a reconcile.

isBootstrapInProgress returns true only if the container that
initiated the bootstrap is still present (matching CID). If the pod
restarted or is gone, the entry is cleared so the operator can
reprobe. injectGcommURI and getPodsWaitingForGcomm remain free
functions with no shared state.

Generated-By: claude-opus-4-6
Signed-off-by: Luca Miccini <lmiccini@redhat.com>
@openshift-ci

openshift-ci Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lmiccini, openshift-cherrypick-robot

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved label Jul 7, 2026
@openshift-merge-bot openshift-merge-bot Bot merged commit 9b81cf9 into openstack-k8s-operators:18.0-fr6 Jul 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants