@@ -44,6 +44,8 @@ const (
4444 EventReasonScale string = "Scaling"
4545
4646 statusHaRetryEnv = "STATUS_HA_RETRY"
47+
48+ lastAppliedConfigAnnotation string = "kubectl.kubernetes.io/last-applied-configuration"
4749)
4850
4951// blank assignment to verify that ReconcileStatefulSet implements reconcile.Reconciler.
@@ -478,6 +480,11 @@ func (in *ReconcileStatefulSet) maybePatchStatefulSet(ctx context.Context, deplo
478480 current .Spec .Template .Spec .Containers [0 ].Args = []string {}
479481 original .Spec .Template .Spec .Containers [0 ].Args = []string {}
480482
483+ // do not patch the annotation "kubectl.kubernetes.io/last-applied-configuration"
484+ delete (desired .Annotations , lastAppliedConfigAnnotation )
485+ delete (original .Annotations , lastAppliedConfigAnnotation )
486+ delete (current .Annotations , lastAppliedConfigAnnotation )
487+
481488 desiredPodSpec := desired .Spec .Template
482489 currentPodSpec := current .Spec .Template
483490 originalPodSpec := original .Spec .Template
@@ -514,6 +521,12 @@ func (in *ReconcileStatefulSet) maybePatchStatefulSet(ctx context.Context, deplo
514521
515522 // fix the CreationTimestamp so that it is not in the patch
516523 desired .SetCreationTimestamp (current .GetCreationTimestamp ())
524+
525+ sa1 := current .Spec .Template .Spec .ServiceAccountName
526+ sa2 := original .Spec .Template .Spec .ServiceAccountName
527+ sa3 := desired .Spec .Template .Spec .ServiceAccountName
528+ logger .Info ("**** About to create patch for StatefulSet" , "CurrentSA" , sa1 , "OriginalSA" , sa2 , "DesiredSA" , sa3 )
529+
517530 // create the patch to see whether there is anything to update
518531 patch , data , err := in .CreateThreeWayPatch (current .GetName (), original , desired , current , patching .PatchIgnore )
519532 if err != nil {
@@ -529,15 +542,15 @@ func (in *ReconcileStatefulSet) maybePatchStatefulSet(ctx context.Context, deplo
529542 // Check we have the expected number of ready replicas
530543 if readyReplicas != currentReplicas {
531544 logger .Info ("Re-queuing update request. StatefulSet Status not all replicas are ready" , "Ready" , readyReplicas , "CurrentReplicas" , currentReplicas )
532- return reconcile.Result {Requeue : true , RequeueAfter : time .Minute }, nil
545+ return reconcile.Result {RequeueAfter : time .Minute }, nil
533546 }
534547
535548 // perform the StatusHA check...
536549 checker := probe.CoherenceProbe {Client : in .GetClient (), Config : in .GetManager ().GetConfig ()}
537550 ha := checker .IsStatusHA (ctx , deployment , current )
538551 if ! ha {
539552 logger .Info ("Coherence cluster is not StatusHA - re-queuing update request." )
540- return reconcile.Result {Requeue : true , RequeueAfter : time .Minute }, nil
553+ return reconcile.Result {RequeueAfter : time .Minute }, nil
541554 }
542555 } else {
543556 // the user specifically set a forced update!
@@ -549,7 +562,7 @@ func (in *ReconcileStatefulSet) maybePatchStatefulSet(ctx context.Context, deplo
549562 suspended := in .suspendServices (ctx , deployment , current )
550563 switch suspended {
551564 case probe .ServiceSuspendFailed :
552- return reconcile.Result {Requeue : true , RequeueAfter : time .Minute }, fmt .Errorf ("failed to suspend services prior to updating single member deployment" )
565+ return reconcile.Result {RequeueAfter : time .Minute }, fmt .Errorf ("failed to suspend services prior to updating single member deployment" )
553566 case probe .ServiceSuspendSkipped :
554567 logger .Info ("Skipping suspension of Coherence services in single member deployment " + deployment .GetName () +
555568 " prior to update StatefulSet" )
@@ -566,7 +579,7 @@ func (in *ReconcileStatefulSet) maybePatchStatefulSet(ctx context.Context, deplo
566579 logger .Info ("Error patching StatefulSet " + err .Error ())
567580 return in .HandleErrAndRequeue (ctx , err , deployment , fmt .Sprintf (FailedToPatchMessage , deployment .GetName (), err .Error ()), logger )
568581 case ! patched :
569- return reconcile.Result {Requeue : true }, nil
582+ return reconcile.Result {RequeueAfter : time . Minute }, nil
570583 }
571584
572585 return reconcile.Result {}, nil
0 commit comments