Skip to content

CLOUDP-321072: set minimum mongodb search version support at 8.2.0 #257

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 3 commits into
base: search/public-preview
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions controllers/search_controller/mongodbsearch_reconcile_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import (
)

const (
MongoDBSearchIndexFieldName = "mdbsearch-for-mongodbresourceref-index"
MongoDBSearchIndexFieldName = "mdbsearch-for-mongodbresourceref-index"
MinimumSupportedMongoDBVersion = "8.2.0"
)

type OperatorSearchConfig struct {
Expand Down Expand Up @@ -237,13 +238,10 @@ func mongotHostAndPort(search *searchv1.MongoDBSearch) string {
}

func ValidateSearchSource(db SearchSourceDBResource) error {
version, err := semver.ParseTolerant(db.GetMongoDBVersion())
err := ValidateMinVersion(db.GetMongoDBVersion(), MinimumSupportedMongoDBVersion)
if err != nil {
return xerrors.Errorf("error parsing MongoDB version '%s': %w", db.GetMongoDBVersion(), err)
} else if version.Major < 8 {
return xerrors.New("MongoDB version must be 8.0 or higher")
return err
}

if db.IsSecurityTLSConfigEnabled() {
return xerrors.New("MongoDBSearch does not support TLS-enabled sources")
}
Expand All @@ -269,3 +267,20 @@ func (r *MongoDBSearchReconcileHelper) ValidateSingleMongoDBSearchForSearchSourc

return nil
}

func ValidateMinVersion(versionStr, minVersionStr string) error {
version, err := semver.ParseTolerant(versionStr)
if err != nil {
return xerrors.Errorf("error parsing MongoDB version '%s': %w", versionStr, err)
}
minVersion, err := semver.ParseTolerant(minVersionStr)
if err != nil {
return xerrors.Errorf("error parsing MongodB minimum version '%s': %w", minVersionStr, err)
}

if version.LT(minVersion) {
return xerrors.Errorf("MongoDBSearch requires MongoDB version %s or higher", minVersionStr)
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func TestMongoDBSearchReconcileHelper_ValidateSearchSource(t *testing.T) {
Version: "4.4.0",
},
},
expectedError: "MongoDB version must be 8.0 or higher",
expectedError: "MongoDBSearch requires MongoDB version 8.2.0 or higher",
},
{
name: "Valid version",
mdbc: mdbcv1.MongoDBCommunity{
ObjectMeta: mdbcMeta,
Spec: mdbcv1.MongoDBCommunitySpec{
Version: "8.0",
Version: "8.2",
},
},
},
Expand All @@ -50,7 +50,7 @@ func TestMongoDBSearchReconcileHelper_ValidateSearchSource(t *testing.T) {
mdbc: mdbcv1.MongoDBCommunity{
ObjectMeta: mdbcMeta,
Spec: mdbcv1.MongoDBCommunitySpec{
Version: "8.0",
Version: "8.2",
Security: mdbcv1.Security{
TLS: mdbcv1.TLS{
Enabled: true,
Expand Down