Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions controllers/operator/construct/database_construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func buildDatabaseStatefulSetConfigurationFunction(mdb databaseStatefulSetSource
appLabelKey: opts.ServiceName,
}

annotationFunc := statefulset.WithAnnotations(defaultPodAnnotations(opts.CertificateHash))
annotationFunc := statefulset.WithAnnotations(defaultStatefulSetAnnotations(opts.CertificateHash))
podTemplateAnnotationFunc := podtemplatespec.NOOP()

annotationFunc = statefulset.Apply(
Expand Down Expand Up @@ -1057,11 +1057,8 @@ func DatabaseStartupProbe() probes.Modification {
)
}

func defaultPodAnnotations(certHash string) map[string]string {
func defaultStatefulSetAnnotations(certHash string) map[string]string {
return map[string]string{
// This annotation is necessary to trigger a pod restart
// if the certificate secret is out of date. This happens if
// existing certificates have been replaced/rotated/renewed.
certs.CertHashAnnotationKey: certHash,
}
}
Expand Down
9 changes: 0 additions & 9 deletions pkg/statefulset/statefulset_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
apiEquality "k8s.io/apimachinery/pkg/api/equality"
apiErrors "k8s.io/apimachinery/pkg/api/errors"

"github.com/mongodb/mongodb-kubernetes/controllers/operator/certs"
"github.com/mongodb/mongodb-kubernetes/controllers/operator/inspect"
"github.com/mongodb/mongodb-kubernetes/controllers/operator/workflow"
kubernetesClient "github.com/mongodb/mongodb-kubernetes/mongodb-community-operator/pkg/kube/client"
Expand Down Expand Up @@ -121,14 +120,6 @@ func CreateOrUpdateStatefulset(ctx context.Context, getUpdateCreator kubernetesC
log.Debug("Created StatefulSet")
return statefulSetToCreate, nil
}
// preserve existing certificate hash if new one is not statefulSetToCreate
existingCertHash, okExisting := existingStatefulSet.Spec.Template.Annotations[certs.CertHashAnnotationKey]
if newCertHash, okNew := statefulSetToCreate.Spec.Template.Annotations[certs.CertHashAnnotationKey]; existingCertHash != "" && newCertHash == "" && okExisting && okNew {
if statefulSetToCreate.Spec.Template.Annotations == nil {
statefulSetToCreate.Spec.Template.Annotations = map[string]string{}
}
statefulSetToCreate.Spec.Template.Annotations[certs.CertHashAnnotationKey] = existingCertHash
}

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