@@ -45,7 +45,7 @@ const (
4545)
4646
4747// blank assignment to verify that ReconcileStatefulSet implements reconcile.Reconciler.
48- // If the reconcile.Reconciler API was to change then we'd get a compile error here.
48+ // If the ` reconcile.Reconciler` API was to change then we'd get a compile error here.
4949var _ reconcile.Reconciler = & ReconcileStatefulSet {}
5050
5151var log = logf .Log .WithName (controllerName )
@@ -397,12 +397,12 @@ func (in *ReconcileStatefulSet) updateStatefulSet(ctx context.Context, deploymen
397397 switch {
398398 case currentReplicas < desiredReplicas :
399399 // scale up - if also updating we do the rolling upgrade first followed by the
400- // scale up so we do not do a rolling upgrade of the bigger scaled up cluster
400+ // scale up so that we do not do a rolling upgrade of the bigger scaled up cluster
401401
402402 // try the patch first
403403 result , err = in .patchStatefulSet (ctx , deployment , current , desired , storage , logger )
404404 if err == nil && ! result .Requeue {
405- // there was nothing else to patch so we can do the scale up
405+ // there was nothing else to patch, so we can do the scale up
406406 result , err = in .scale (ctx , deployment , current , currentReplicas , desiredReplicas )
407407 }
408408 case currentReplicas > desiredReplicas :
@@ -411,7 +411,7 @@ func (in *ReconcileStatefulSet) updateStatefulSet(ctx context.Context, deploymen
411411
412412 // do the scale down
413413 _ , err = in .scale (ctx , deployment , current , currentReplicas , desiredReplicas )
414- // requeue the request so we do any upgrade next time around
414+ // requeue the request so that we do any upgrade next time around
415415 result .Requeue = true
416416 default :
417417 // just an update
@@ -441,8 +441,16 @@ func (in *ReconcileStatefulSet) patchStatefulSet(ctx context.Context, deployment
441441 original = desired
442442 }
443443
444+ errorList := coh .ValidateStatefulSetUpdate (desired , original )
445+ if len (errorList ) > 0 {
446+ msg := fmt .Sprintf ("upddates to the statefuleset would have been invalid, the update will not be re-queued: %v" , errorList )
447+ events := in .GetEventRecorder ()
448+ events .Event (deployment , corev1 .EventTypeWarning , reconciler .EventReasonUpdated , msg )
449+ return reconcile.Result {Requeue : false }, fmt .Errorf (msg )
450+ }
451+
444452 // We NEVER change the replicas or Status in an update.
445- // Replicas is handled by scaling so we always set the desired replicas to match the current replicas
453+ // Replicas is handled by scaling, so we always set the desired replicas to match the current replicas
446454 desired .Spec .Replicas = current .Spec .Replicas
447455 original .Spec .Replicas = current .Spec .Replicas
448456
@@ -451,7 +459,7 @@ func (in *ReconcileStatefulSet) patchStatefulSet(ctx context.Context, deployment
451459 desired .ObjectMeta .Finalizers = current .ObjectMeta .Finalizers
452460
453461 // We need to ensure we do not create a patch due to differences in
454- // StatefulSet Status so we blank out the status fields
462+ // StatefulSet Status, so we blank out the status fields
455463 desired .Status = appsv1.StatefulSetStatus {}
456464 current .Status = appsv1.StatefulSetStatus {}
457465 original .Status = appsv1.StatefulSetStatus {}
@@ -465,7 +473,7 @@ func (in *ReconcileStatefulSet) patchStatefulSet(ctx context.Context, deployment
465473
466474 // ensure we do not patch any fields that may be set by a previous version of the Operator
467475 // as this will cause a rolling update of the Pods, typically these are fields where
468- // the Operator sets defaults and we changed the default behaviour
476+ // the Operator sets defaults, and we changed the default behaviour
469477 in .blankContainerFields (deployment , desired )
470478 in .blankContainerFields (deployment , current )
471479 in .blankContainerFields (deployment , original )
@@ -663,7 +671,7 @@ func (in *ReconcileStatefulSet) blankOperatorInitContainerFields(sts *appsv1.Sta
663671
664672// Blanks out any fields that may have been set by a previous Operator version.
665673// DO NOT blank out anything that the user has control over as they may have
666- // updated them so we need to include them in the patch
674+ // updated them, so we need to include them in the patch
667675func (in * ReconcileStatefulSet ) blankCoherenceContainerFields (sts * appsv1.StatefulSet ) {
668676 for i := range sts .Spec .Template .Spec .Containers {
669677 c := sts .Spec .Template .Spec .Containers [i ]
0 commit comments