Skip to content

Commit

Permalink
Merge pull request #255 from dciabrin/1node-restart
Browse files Browse the repository at this point in the history
Do not start galera as joiner with 1-replica cluster
  • Loading branch information
openshift-merge-bot[bot] authored Aug 6, 2024
2 parents a375644 + 4beccf3 commit f02e6ea
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions controllers/galera_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ func (r *GaleraReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
// Note:
// . A pod is available in the statefulset if the pod's readiness
// probe returns true (i.e. galera is running in the pod and clustered)
// . Cluster is bootstrapped if as soon as one pod is available
// . Cluster is bootstrapped as soon as one pod is available
instance.Status.Bootstrapped = statefulset.Status.AvailableReplicas > 0

if instance.Status.Bootstrapped {
Expand All @@ -708,8 +708,17 @@ func (r *GaleraReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
}
}

runningPods := getRunningPodsMissingGcomm(ctx, podList.Items, instance, helper, r.config)
// Special case for 1-node deployment: if the statefulset reports 1 node is available
// but the pod shows up in runningPods (i.e. NotReady), do not consider it a joiner.
// Wait for the two statuses to re-sync after another k8s probe is run.
if *instance.Spec.Replicas == 1 && len(runningPods) == 1 {
log.Info("Galera node no longer running. Requeuing")
return ctrl.Result{RequeueAfter: time.Duration(3) * time.Second}, nil
}

// The other 'Running' pods can join the existing cluster.
for _, pod := range getRunningPodsMissingGcomm(ctx, podList.Items, instance, helper, r.config) {
for _, pod := range runningPods {
name := pod.Name
joinerURI := buildGcommURI(instance)
log.Info("Pushing gcomm URI to joiner", "pod", name)
Expand Down

0 comments on commit f02e6ea

Please sign in to comment.