-
Notifications
You must be signed in to change notification settings - Fork 11
CLOUDP-321075: fail to reconcile mongo db search for version 1.47.0 #244
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
base: search/public-preview
Are you sure you want to change the base?
CLOUDP-321075: fail to reconcile mongo db search for version 1.47.0 #244
Conversation
…cile-MongoDBSearch-for-version-1.47.0
controllers/search_controller/mongodbsearch_reconcile_helper.go
Outdated
Show resolved
Hide resolved
controllers/search_controller/mongodbsearch_reconcile_helper.go
Outdated
Show resolved
Hide resolved
func (r *MongoDBSearchReconcileHelper) getMongotImage() string { | ||
version := strings.TrimSpace(r.mdbSearch.Spec.Version) | ||
if version != "" { | ||
return version |
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.
I find the method a bit confusing what is really returned. In this codepath we'll get a version, but below we'll return a full image (which is also consistent with the method name).
I'd recommend renaming the method to getMongotVersion() and return an actual version tag from the container.Image. Be also mindful that this container.Image might contain digest pinned image instead of a semver tag.
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.
I would say that I just change the function name to getMongotImageOrVersion
because at the end we just need to do a string contains operation and we can live without over-engineering this temporary code.
Wdyt?
@@ -203,3 +203,13 @@ func TestMongoDBSearchReconcile_MultipleSearchResources(t *testing.T) { | |||
|
|||
checkSearchReconcileFailed(ctx, t, reconciler, c, search1, "multiple MongoDBSearch") | |||
} | |||
|
|||
func TestMongoDBSearchReconcile_InvalidSearchImageVersion(t *testing.T) { |
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.
can we add a testcase for the statefulset codepath? I'd do it by doing the reconcile and then updating search.Spec.Version to "" (not sure if that will work)
MongoDBSearchIndexFieldName = "mdbsearch-for-mongodbresourceref-index" | ||
MongoDBSearchIndexFieldName = "mdbsearch-for-mongodbresourceref-index" | ||
unsupportedSearchVersion = "1.47.0" | ||
unsupportedSearchVersionErrorFmt = "MongoDBSearch version %s is not supported" |
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.
Can we make this error message more informative for the user? Let's mention why it's not supported, how the operator is treating it (ignoring it essentially), and perhaps that the existing workload will still work but cannot be reconfigured by the operator and they need to start from scratch.
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.
This sounds like something that needs to be in the docs.
Would a doc link be more helpful?
…cile-MongoDBSearch-for-version-1.47.0
Summary
This pull request introduces validation for unsupported MongoDBSearch image versions and adds a corresponding test case. The key changes include implementing a new validation method, updating the reconciliation logic, and adding constants for unsupported versions.
Validation for unsupported MongoDBSearch image versions:
New validation method: Added
ValidateSearchImageVersion
toMongoDBSearchReconcileHelper
to check if the specified or container image version matches an unsupported version (1.47.0
). If so, it returns an error.Integration into reconciliation workflow: Updated the
reconcile
method to invokeValidateSearchImageVersion
before proceeding with other validations.Constants for unsupported version: Introduced
unsupportedSearchVersion
andunsupportedSearchVersionErrorFmt
constants to centralize the unsupported version logic and error formatting.Test case for validation:
TestMongoDBSearchReconcile_InvalidSearchImageVersion
to validate the error handling for unsupported MongoDBSearch versions. This ensures the reconciliation fails with the appropriate error message.Proof of Work
Test pass
Checklist
Reminder (Please remove this when merging)