Skip to content

Commit 77c55dc

Browse files
committed
Remove outdated code
This piece of code is meant to preserve cert hash annotation in the pod template. We currently do not use cert hash annotation on the pod: we only use sts level annotations.
1 parent b90c986 commit 77c55dc

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

controllers/operator/construct/database_construction.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ func buildDatabaseStatefulSetConfigurationFunction(mdb databaseStatefulSetSource
466466
appLabelKey: opts.ServiceName,
467467
}
468468

469-
annotationFunc := statefulset.WithAnnotations(defaultPodAnnotations(opts.CertificateHash))
469+
annotationFunc := statefulset.WithAnnotations(defaultSatefulSetAnnotations(opts.CertificateHash))
470470
podTemplateAnnotationFunc := podtemplatespec.NOOP()
471471

472472
annotationFunc = statefulset.Apply(
@@ -1057,11 +1057,8 @@ func DatabaseStartupProbe() probes.Modification {
10571057
)
10581058
}
10591059

1060-
func defaultPodAnnotations(certHash string) map[string]string {
1060+
func defaultSatefulSetAnnotations(certHash string) map[string]string {
10611061
return map[string]string{
1062-
// This annotation is necessary to trigger a pod restart
1063-
// if the certificate secret is out of date. This happens if
1064-
// existing certificates have been replaced/rotated/renewed.
10651062
certs.CertHashAnnotationKey: certHash,
10661063
}
10671064
}

pkg/statefulset/statefulset_util.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
apiEquality "k8s.io/apimachinery/pkg/api/equality"
2020
apiErrors "k8s.io/apimachinery/pkg/api/errors"
2121

22-
"github.com/mongodb/mongodb-kubernetes/controllers/operator/certs"
2322
"github.com/mongodb/mongodb-kubernetes/controllers/operator/inspect"
2423
"github.com/mongodb/mongodb-kubernetes/controllers/operator/workflow"
2524
kubernetesClient "github.com/mongodb/mongodb-kubernetes/mongodb-community-operator/pkg/kube/client"
@@ -121,14 +120,6 @@ func CreateOrUpdateStatefulset(ctx context.Context, getUpdateCreator kubernetesC
121120
log.Debug("Created StatefulSet")
122121
return statefulSetToCreate, nil
123122
}
124-
// preserve existing certificate hash if new one is not statefulSetToCreate
125-
existingCertHash, okExisting := existingStatefulSet.Spec.Template.Annotations[certs.CertHashAnnotationKey]
126-
if newCertHash, okNew := statefulSetToCreate.Spec.Template.Annotations[certs.CertHashAnnotationKey]; existingCertHash != "" && newCertHash == "" && okExisting && okNew {
127-
if statefulSetToCreate.Spec.Template.Annotations == nil {
128-
statefulSetToCreate.Spec.Template.Annotations = map[string]string{}
129-
}
130-
statefulSetToCreate.Spec.Template.Annotations[certs.CertHashAnnotationKey] = existingCertHash
131-
}
132123

133124
// there already exists a pvc size annotation, that means we did resize at least once
134125
// we need to make sure to keep the annotation.

0 commit comments

Comments
 (0)