diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index f75988f..d46ab19 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -1291,6 +1291,7 @@ func updatedStatefulSet( // annotation. This ensures that users can always set an update annotation and then // wait for it to be removed to know if the operator has processed a StatefulSet. if !update { + updateSpecTemplate(actual) delete(actual.Annotations, annotations.Update) delete(actual.Annotations, annotations.ParallelUpdate) return actual, true, nil @@ -1304,9 +1305,20 @@ func updatedStatefulSet( expected.Status = actual.DeepCopy().Status copyAnnotations(expected, actual) + updateSpecTemplate(expected) return expected, true, nil } +// updates spec template so that rollout update is always performed. +func updateSpecTemplate(sts *appsv1.StatefulSet) { + if sts.Spec.Template.Annotations == nil { + sts.Spec.Template.Annotations = map[string]string{} + } + + now, _ := metav1.Now().MarshalQueryParameter() + sts.Spec.Template.Annotations[annotations.Rollout] = now +} + func copyAnnotations(expected, actual *appsv1.StatefulSet) { // It's okay for users to add annotations to a StatefulSet after it has been created so // we'll want to copy over any that exist on the actual StatefulSet but not the expected diff --git a/pkg/k8sops/annotations/annotations.go b/pkg/k8sops/annotations/annotations.go index 6544064..d7f0b23 100644 --- a/pkg/k8sops/annotations/annotations.go +++ b/pkg/k8sops/annotations/annotations.go @@ -43,6 +43,9 @@ const ( // ParallelUpdateInProgress is the annotation used by the operator indicate a parallel update // is underway. This annotation should only be used by the operator. ParallelUpdateInProgress = "operator.m3db.io/parallel-update-in-progress" + // Rollout is the annotation used by the operator to force rollout update of a StatefulSet. + Rollout = "operator.m3db.io/rollout" + // EnabledVal is the value that indicates an annotation is enabled. EnabledVal = "enabled" )