-
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?
Changes from all commits
17d4a45
5ae3b26
e7699b3
5833c36
42d3d6d
c77b138
aa6c75d
d849a15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,12 @@ import ( | |
) | ||
|
||
const ( | ||
MongoDBSearchIndexFieldName = "mdbsearch-for-mongodbresourceref-index" | ||
MongoDBSearchIndexFieldName = "mdbsearch-for-mongodbresourceref-index" | ||
unsupportedSearchVersion = "1.47.0" | ||
unsupportedSearchVersionErrorFmt = "MongoDBSearch version %s is not supported because of breaking changes. " + | ||
"The operator will ignore this resource: it will not reconcile or reconfigure the workload. " + | ||
"Existing deployments will continue to run, but cannot be managed by the operator. " + | ||
"To regain operator management, you must delete and recreate the MongoDBSearch resource." | ||
) | ||
|
||
type OperatorSearchConfig struct { | ||
|
@@ -81,6 +86,10 @@ func (r *MongoDBSearchReconcileHelper) reconcile(ctx context.Context, log *zap.S | |
return workflow.Failed(err) | ||
} | ||
|
||
if err := r.ValidateSearchImageVersion(); err != nil { | ||
return workflow.Failed(err) | ||
} | ||
|
||
if err := r.ValidateSingleMongoDBSearchForSearchSource(ctx); err != nil { | ||
return workflow.Failed(err) | ||
} | ||
|
@@ -402,8 +411,44 @@ func (r *MongoDBSearchReconcileHelper) ValidateSingleMongoDBSearchForSearchSourc | |
for i, search := range searchList.Items { | ||
resourceNames[i] = search.Name | ||
} | ||
return xerrors.Errorf("Found multiple MongoDBSearch resources for search source '%s': %s", r.db.Name(), strings.Join(resourceNames, ", ")) | ||
return xerrors.Errorf( | ||
"Found multiple MongoDBSearch resources for search source '%s': %s", r.db.Name(), | ||
strings.Join(resourceNames, ", "), | ||
) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (r *MongoDBSearchReconcileHelper) ValidateSearchImageVersion() error { | ||
version := r.getMongotImage() | ||
|
||
if strings.Contains(version, unsupportedSearchVersion) { | ||
return xerrors.Errorf(unsupportedSearchVersionErrorFmt, unsupportedSearchVersion) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (r *MongoDBSearchReconcileHelper) getMongotImage() string { | ||
version := strings.TrimSpace(r.mdbSearch.Spec.Version) | ||
if version != "" { | ||
fealebenpae marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return version | ||
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. 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 commentThe reason will be displayed to describe this comment to others. Learn more. I would say that I just change the function name to |
||
} | ||
|
||
if r.operatorSearchConfig.SearchVersion != "" { | ||
return r.operatorSearchConfig.SearchVersion | ||
} | ||
|
||
if r.mdbSearch.Spec.StatefulSetConfiguration == nil { | ||
return "" | ||
} | ||
|
||
for _, container := range r.mdbSearch.Spec.StatefulSetConfiguration.SpecWrapper.Spec.Template.Spec.Containers { | ||
if container.Name == MongotContainerName { | ||
return container.Image | ||
} | ||
} | ||
|
||
return "" | ||
} |
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)