-
Notifications
You must be signed in to change notification settings - Fork 23
CLOUDP: 327089, CLOUDP: 317939 add status field #554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
anandsyncs
wants to merge
2
commits into
master
Choose a base branch
from
CLOUDP-327089-add-status-field
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+94
−12
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package search | ||
|
|
||
| import "github.com/mongodb/mongodb-kubernetes/api/v1/status" | ||
|
|
||
| type MongoDBSearchVersionOption struct { | ||
| Version string | ||
| } | ||
|
|
||
| var _ status.Option = MongoDBSearchVersionOption{} | ||
|
|
||
| func NewMongoDBSearchVersionOption(version string) MongoDBSearchVersionOption { | ||
| return MongoDBSearchVersionOption{Version: version} | ||
| } | ||
|
|
||
| func (o MongoDBSearchVersionOption) Value() interface{} { | ||
| return o.Version | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| title: Surface reconciled MongoDBSearch version | ||
| kind: fix | ||
| date: 2025-10-24 | ||
| --- | ||
|
|
||
| * MongoDBSearch now records the reconciled mongot version in status and exposes it via a dedicated kubectl print column. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,7 +172,12 @@ func TestMongoDBSearchReconcile_Success(t *testing.T) { | |
| search.Spec.LogLevel = "WARN" | ||
|
|
||
| mdbc := newMongoDBCommunity("mdb", mock.TestNamespace) | ||
| reconciler, c := newSearchReconciler(mdbc, search) | ||
| operatorConfig := searchcontroller.OperatorSearchConfig{ | ||
| SearchRepo: "testrepo", | ||
| SearchName: "mongot", | ||
| SearchVersion: "1.48.0", | ||
| } | ||
| reconciler, c := newSearchReconcilerWithOperatorConfig(mdbc, operatorConfig, search) | ||
|
|
||
| res, err := reconciler.Reconcile( | ||
| ctx, | ||
|
|
@@ -182,6 +187,11 @@ func TestMongoDBSearchReconcile_Success(t *testing.T) { | |
| assert.NoError(t, err) | ||
| assert.Equal(t, expected, res) | ||
|
|
||
| // BEFORE readiness: version should still be empty (controller sets Version only after StatefulSet ready) | ||
| searchPending := &searchv1.MongoDBSearch{} | ||
| assert.NoError(t, c.Get(ctx, types.NamespacedName{Name: search.Name, Namespace: search.Namespace}, searchPending)) | ||
| assert.Empty(t, searchPending.Status.Version, "Status.Version must be empty before StatefulSet is marked ready") | ||
|
|
||
| svc := &corev1.Service{} | ||
| err = c.Get(ctx, search.SearchServiceNamespacedName(), svc) | ||
| assert.NoError(t, err) | ||
|
|
@@ -194,9 +204,18 @@ func TestMongoDBSearchReconcile_Success(t *testing.T) { | |
| assert.NoError(t, err) | ||
| assert.Equal(t, string(configYaml), cm.Data[searchcontroller.MongotConfigFilename]) | ||
|
|
||
| sts := &appsv1.StatefulSet{} | ||
| err = c.Get(ctx, search.StatefulSetNamespacedName(), sts) | ||
| markStatefulSetReady(ctx, t, c, search.StatefulSetNamespacedName()) | ||
|
|
||
| res, err = reconciler.Reconcile( | ||
| ctx, | ||
| reconcile.Request{NamespacedName: types.NamespacedName{Name: search.Name, Namespace: search.Namespace}}, | ||
| ) | ||
| assert.NoError(t, err) | ||
| assert.Equal(t, expected, res) | ||
|
|
||
| updatedSearch := &searchv1.MongoDBSearch{} | ||
| assert.NoError(t, c.Get(ctx, types.NamespacedName{Name: search.Name, Namespace: search.Namespace}, updatedSearch)) | ||
| assert.Equal(t, operatorConfig.SearchVersion, updatedSearch.Status.Version) | ||
| } | ||
|
|
||
| func checkSearchReconcileFailed( | ||
|
|
@@ -296,3 +315,18 @@ func TestMongoDBSearchReconcile_InvalidSearchImageVersion(t *testing.T) { | |
| }) | ||
| } | ||
| } | ||
|
|
||
| func markStatefulSetReady(ctx context.Context, t *testing.T, c client.Client, name types.NamespacedName) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider using https://github.com/mongodb/mongodb-kubernetes/blob/master/controllers/operator/mock/mockedkubeclient.go#L136 |
||
| t.Helper() | ||
|
|
||
| sts := &appsv1.StatefulSet{} | ||
| assert.NoError(t, c.Get(ctx, name, sts)) | ||
|
|
||
| sts.Status.UpdatedReplicas = 1 | ||
| sts.Status.ReadyReplicas = 1 | ||
| sts.Status.CurrentReplicas = 1 | ||
| sts.Status.Replicas = 1 | ||
| sts.Status.ObservedGeneration = sts.Generation | ||
|
|
||
| assert.NoError(t, c.Status().Update(ctx, sts)) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!