Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit 1c12c9f

Browse files
authored
CLOUDP-92134: Fix Flakey Version Changing (#566)
1 parent b4e97f7 commit 1c12c9f

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

controllers/replica_set_controller.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const (
5656
clusterDNSName = "CLUSTER_DNS_NAME"
5757

5858
lastSuccessfulConfiguration = "mongodb.com/v1.lastSuccessfulConfiguration"
59+
lastAppliedMongoDBVersion = "mongodb.com/v1.lastAppliedMongoDBVersion"
5960
)
6061

6162
func init() {
@@ -232,11 +233,6 @@ func (r ReplicaSetReconciler) Reconcile(ctx context.Context, request reconcile.R
232233
r.log.Errorf("Could not update connection string secrets: %s", err)
233234
}
234235

235-
// the last version will be duplicated in two annotations.
236-
// This is needed to reuse the update strategy logic in enterprise
237-
if err := annotations.UpdateLastAppliedMongoDBVersion(&mdb, r.client); err != nil {
238-
r.log.Errorf("Could not save current version as an annotation: %s", err)
239-
}
240236
if err := r.updateLastSuccessfulConfiguration(mdb); err != nil {
241237
r.log.Errorf("Could not save current spec as an annotation: %s", err)
242238
}
@@ -259,6 +255,9 @@ func (r *ReplicaSetReconciler) updateLastSuccessfulConfiguration(mdb mdbv1.Mongo
259255

260256
specAnnotations := map[string]string{
261257
lastSuccessfulConfiguration: string(currentSpec),
258+
// the last version will be duplicated in two annotations.
259+
// This is needed to reuse the update strategy logic in enterprise
260+
lastAppliedMongoDBVersion: mdb.Spec.Version,
262261
}
263262
return annotations.SetAnnotations(&mdb, specAnnotations, r.client)
264263
}

controllers/replicaset_controller_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,22 @@ func TestIgnoreUnknownUsers(t *testing.T) {
523523
mdb.Spec.Security.Authentication.IgnoreUnknownUsers = &ignoreUnknownUsers
524524
assertAuthoritativeSet(t, mdb, true)
525525
})
526+
}
527+
528+
func TestAnnotationsAreAppliedToResource(t *testing.T) {
529+
mdb := newTestReplicaSet()
530+
531+
mgr := client.NewManager(&mdb)
532+
r := NewReconciler(mgr)
533+
res, err := r.Reconcile(context.TODO(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: mdb.Namespace, Name: mdb.Name}})
534+
assertReconciliationSuccessful(t, res, err)
535+
536+
err = mgr.GetClient().Get(context.TODO(), mdb.NamespacedName(), &mdb)
537+
assert.NoError(t, err)
526538

539+
assert.NotNil(t, mdb.Annotations)
540+
assert.NotEmpty(t, mdb.Annotations[lastSuccessfulConfiguration], "last successful spec should have been saved as annotation but was not")
541+
assert.Equal(t, mdb.Annotations[lastAppliedMongoDBVersion], mdb.Spec.Version, "last version should have been saved as an annotation but was not")
527542
}
528543

529544
// assertAuthoritativeSet asserts that a reconciliation of the given MongoDBCommunity resource

docs/RELEASE_NOTES.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
1-
# MongoDB Kubernetes Operator 0.6.1
1+
# MongoDB Kubernetes Operator 0.6.2
22

33
## Kubernetes Operator
4-
5-
- Bug fixes
6-
- when deleting MongoDB Resource cleanup related resources (k8s services, secrets).
74

85
- Changes
9-
- fixed an issue where the operator would reconcile based on events emitted by itself in certain situations.
10-
- support connection strings using SRV.
11-
- expose connection strings (including auth/tls values) for deployments as secrets for easy of use. Secrets name template: _\<MongoDB resource name\>-\<db\>-\<user\>_
12-
13-
## MongoDB Agent ReadinessProbe
14-
15-
- Changes
16-
- Readiness probe now patches pod annotations rather than overwriting them.
17-
18-
## Miscellaneous
19-
Ubuntu-based agent images are now based on Ubuntu 20.04 instead of Ubuntu 16.06
6+
- stability improvements when changing version of MongoDB.
207

218
## Updated Image Tags
229

23-
- mongodb-kubernetes-operator:0.6.1
24-
- mongodb-kubernetes-readinessprobe:1.0.4
10+
- mongodb-kubernetes-operator:0.6.2
2511

2612
_All the images can be found in:_
2713

test/e2e/replica_set_change_version/replica_set_test.go renamed to test/e2e/replica_set_change_version/replica_set_change_version_test.go

File renamed without changes.

0 commit comments

Comments
 (0)