diff --git a/pkg/cluster/util.go b/pkg/cluster/util.go index 42917fd24..81b715801 100644 --- a/pkg/cluster/util.go +++ b/pkg/cluster/util.go @@ -70,7 +70,8 @@ func metadataAnnotationsPatch(annotations map[string]string) string { annotationsList = append(annotationsList, fmt.Sprintf(`"%s":"%s"`, name, value)) } annotationsString := strings.Join(annotationsList, ",") - return fmt.Sprintf(`{"metadata":{"annotations": {"$patch":"replace", %s}}}`, annotationsString) + // TODO: perhaps use patchStrategy:"replace" json annotation instead of constructing the patch literally. + return fmt.Sprintf(constants.ServiceMetadataAnnotationFormat, annotationsString) } func (c *Cluster) logStatefulSetChanges(old, new *v1beta1.StatefulSet, isUpdate bool, reasons []string) { diff --git a/pkg/util/constants/annotations.go b/pkg/util/constants/annotations.go index 0b93fc2e1..3b276cc3d 100644 --- a/pkg/util/constants/annotations.go +++ b/pkg/util/constants/annotations.go @@ -7,4 +7,5 @@ const ( ElbTimeoutAnnotationValue = "3600" KubeIAmAnnotation = "iam.amazonaws.com/role" VolumeStorateProvisionerAnnotation = "pv.kubernetes.io/provisioned-by" + ServiceMetadataAnnotationFormat = `{"metadata":{"annotations": {"$patch":"replace", %s}}}` )