Skip to content

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

Open
wants to merge 8 commits into
base: search/public-preview
Choose a base branch
from

Conversation

anandsyncs
Copy link
Contributor

@anandsyncs anandsyncs commented Jul 9, 2025

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 to MongoDBSearchReconcileHelper 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 invoke ValidateSearchImageVersion before proceeding with other validations.

  • Constants for unsupported version: Introduced unsupportedSearchVersion and unsupportedSearchVersionErrorFmt constants to centralize the unsupported version logic and error formatting.

Test case for validation:

  • New test: Added 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

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you checked for release_note changes?

Reminder (Please remove this when merging)

  • Please try to Approve or Reject Changes the PR, keep PRs in review as short as possible
  • Our Short Guide for PRs: Link
  • Remember the following Communication Standards - use comment prefixes for clarity:
    • blocking: Must be addressed before approval.
    • follow-up: Can be addressed in a later PR or ticket.
    • q: Clarifying question.
    • nit: Non-blocking suggestions.
    • note: Side-note, non-actionable. Example: Praise
    • --> no prefix is considered a question

@anandsyncs anandsyncs changed the base branch from master to search/public-preview July 10, 2025 14:04
@anandsyncs anandsyncs marked this pull request as ready for review July 14, 2025 12:46
@anandsyncs anandsyncs requested a review from a team as a code owner July 14, 2025 12:46
@anandsyncs anandsyncs requested review from fealebenpae, lucian-tosa and lsierant and removed request for a team and lucian-tosa July 14, 2025 12:46
@anandsyncs anandsyncs requested a review from fealebenpae July 17, 2025 09:10
@anandsyncs anandsyncs requested a review from fealebenpae July 17, 2025 13:38
func (r *MongoDBSearchReconcileHelper) getMongotImage() string {
version := strings.TrimSpace(r.mdbSearch.Spec.Version)
if version != "" {
return version
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

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"
Copy link
Contributor

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.

Copy link
Contributor Author

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?

@anandsyncs anandsyncs requested a review from lsierant July 22, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants