Skip to content

Commit

Permalink
operator: fix bug that rolls pods that have no changes
Browse files Browse the repository at this point in the history
(cherry picked from commit cfeb1e0)
  • Loading branch information
joejulian authored and vbotbuildovich committed Aug 30, 2023
1 parent 21e6b92 commit d10f00e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/go/k8s/pkg/resources/statefulset_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,22 +386,31 @@ func (r *StatefulSetResource) podEviction(ctx context.Context, pod, artificialPo
ignoreExistingVolumes(newVolumes),
}

managedDecommission, err := r.IsManagedDecommission()
if err != nil {
log.Error(err, "not performing a managed decommission")
}

patchResult, err := patch.NewPatchMaker(patch.NewAnnotator(redpandaAnnotatorKey), &patch.K8sStrategicMergePatcher{}, &patch.BaseJSONMergePatcher{}).Calculate(pod, artificialPod, opts...)
if err != nil {
return err
}

if !managedDecommission && patchResult.IsEmpty() {
podPatch := k8sclient.MergeFrom(pod.DeepCopy())
utils.RemoveStatusPodCondition(&pod.Status.Conditions, ClusterUpdatePodCondition)
if err = r.Client.Status().Patch(ctx, pod, podPatch); err != nil {
return fmt.Errorf("error removing pod update condition: %w", err)
}
return nil
}

var ordinal int32
ordinal, err = utils.GetPodOrdinal(pod.Name, r.pandaCluster.Name)
if err != nil {
return fmt.Errorf("cluster %s: cannot convert pod name (%s) to ordinal: %w", r.pandaCluster.Name, pod.Name, err)
}

managedDecommission, err := r.IsManagedDecommission()
if err != nil {
log.Error(err, "not performing a managed decommission")
}

if *r.pandaCluster.Spec.Replicas == 1 {
log.Info("Changes in Pod definition other than activeDeadlineSeconds, configurator and Redpanda container name. Deleting pod",
"pod-name", pod.Name,
Expand Down

0 comments on commit d10f00e

Please sign in to comment.