Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
kind: other
date: 2025-10-15
---

* Simplified MongoDB Search setup: Removed the custom Search Coordinator polyfill (a piece of compatibility code previously needed to add the required permissions), as MongoDB 8.2.0 and later now include the necessary permissions via the built-in searchCoordinator role.
9 changes: 0 additions & 9 deletions controllers/operator/mongodbreplicaset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,15 +866,6 @@ func (r *ReplicaSetReconcilerHelper) applySearchOverrides(ctx context.Context) b
searchMongodConfig := searchcontroller.GetMongodConfigParameters(search, rs.Spec.GetClusterDomain())
rs.Spec.AdditionalMongodConfig.AddOption("setParameter", searchMongodConfig["setParameter"])

if searchcontroller.NeedsSearchCoordinatorRolePolyfill(rs.Spec.GetMongoDBVersion()) {
log.Infof("Polyfilling the searchCoordinator role for MongoDB %s", rs.Spec.GetMongoDBVersion())

if rs.Spec.Security == nil {
rs.Spec.Security = &mdbv1.Security{}
}
rs.Spec.Security.Roles = append(rs.Spec.Security.Roles, searchcontroller.SearchCoordinatorRole())
}

return true
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/operator/mongodbsearch_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func newMongoDBCommunity(name, namespace string) *mdbcv1.MongoDBCommunity {
Spec: mdbcv1.MongoDBCommunitySpec{
Type: mdbcv1.ReplicaSet,
Members: 1,
Version: "8.0.10",
Version: "8.2.0",
},
}
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/searchcontroller/community_search_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func (r *CommunitySearchSource) Validate() error {
version, err := semver.ParseTolerant(r.GetMongoDBVersion())
if err != nil {
return xerrors.Errorf("error parsing MongoDB version '%s': %w", r.Spec.Version, err)
} else if version.LT(semver.MustParse("8.0.10")) {
return xerrors.New("MongoDB version must be 8.0.10 or higher")
} else if version.LT(semver.MustParse("8.2.0")) {
return xerrors.New("MongoDB version must be 8.2.0 or higher")
}

foundScram := false
Expand Down
46 changes: 23 additions & 23 deletions controllers/searchcontroller/community_search_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,120 +50,120 @@ func TestCommunitySearchSource_Validate(t *testing.T) {
version: "7.0.0",
authModes: []mdbcv1.AuthMode{"SCRAM-SHA-256"},
expectError: true,
expectedErrMsg: "MongoDB version must be 8.0.10 or higher",
expectedErrMsg: "MongoDB version must be 8.2.0 or higher",
},
{
name: "Version just below minimum",
version: "8.0.9",
version: "8.1.9",
authModes: []mdbcv1.AuthMode{"SCRAM-SHA-256"},
expectError: true,
expectedErrMsg: "MongoDB version must be 8.0.10 or higher",
expectedErrMsg: "MongoDB version must be 8.2.0 or higher",
},
{
name: "Valid minimum version",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"SCRAM-SHA-256"},
expectError: false,
},
{
name: "Version above minimum",
version: "8.1.0",
version: "8.3.0",
authModes: []mdbcv1.AuthMode{"SCRAM-SHA-256"},
expectError: false,
},
{
name: "Version with build number",
version: "8.1.0-rc1",
version: "8.3.0-rc1",
authModes: []mdbcv1.AuthMode{"SCRAM-SHA-256"},
expectError: false,
},
// Authentication mode tests - empty/nil cases
{
name: "Empty auth modes",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{},
expectError: false,
},
{
name: "Nil auth modes",
version: "8.0.10",
version: "8.2.0",
authModes: nil,
expectError: false,
},
{
name: "X509 mode only",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"X509"},
expectError: true,
expectedErrMsg: "MongoDBSearch requires SCRAM authentication to be enabled",
},
{
name: "X509 and SCRAM",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"X509", "SCRAM-SHA-256"},
expectError: false,
},
{
name: "Multiple auth modes with SCRAM first",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"SCRAM-SHA-1", "X509"},
expectError: false,
},
{
name: "Multiple auth modes with SCRAM last",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"PLAIN", "X509", "SCRAM-SHA-256"},
expectError: false,
},
{
name: "Multiple non-SCRAM modes",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"PLAIN", "X509"},
expectError: true,
expectedErrMsg: "MongoDBSearch requires SCRAM authentication to be enabled",
},
// SCRAM variant tests
{
name: "SCRAM only",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"SCRAM"},
expectError: false,
},
{
name: "SCRAM-SHA-1 only",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"SCRAM-SHA-1"},
expectError: false,
},
{
name: "SCRAM-SHA-256 only",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"SCRAM-SHA-256"},
expectError: false,
},
{
name: "All SCRAM variants",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"SCRAM", "SCRAM-SHA-1", "SCRAM-SHA-256"},
expectError: false,
},
// Case-insensitive tests (now supported with ToUpper)
{
name: "Lowercase SCRAM",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"scram-sha-256"},
expectError: false,
},
{
name: "Mixed case SCRAM",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"Scram-Sha-256"},
expectError: false,
},
// Edge case tests
{
name: "PLAIN only",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"PLAIN"},
expectError: true,
expectedErrMsg: "MongoDBSearch requires SCRAM authentication to be enabled",
Expand All @@ -174,11 +174,11 @@ func TestCommunitySearchSource_Validate(t *testing.T) {
version: "7.0.0",
authModes: []mdbcv1.AuthMode{"SCRAM-SHA-256"},
expectError: true,
expectedErrMsg: "MongoDB version must be 8.0.10 or higher",
expectedErrMsg: "MongoDB version must be 8.2.0 or higher",
},
{
name: "Valid version with invalid auth",
version: "8.0.10",
version: "8.2.0",
authModes: []mdbcv1.AuthMode{"X509"},
expectError: true,
expectedErrMsg: "MongoDBSearch requires SCRAM authentication to be enabled",
Expand All @@ -188,7 +188,7 @@ func TestCommunitySearchSource_Validate(t *testing.T) {
version: "7.0.0",
authModes: []mdbcv1.AuthMode{"X509"},
expectError: true,
expectedErrMsg: "MongoDB version must be 8.0.10 or higher", // Should fail on version first
expectedErrMsg: "MongoDB version must be 8.2.0 or higher", // Should fail on version first
},
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/searchcontroller/enterprise_search_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func (r EnterpriseResourceSearchSource) Validate() error {
version, err := semver.ParseTolerant(util.StripEnt(r.Spec.GetMongoDBVersion()))
if err != nil {
return xerrors.Errorf("error parsing MongoDB version '%s': %w", r.Spec.GetMongoDBVersion(), err)
} else if version.LT(semver.MustParse("8.0.10")) {
return xerrors.New("MongoDB version must be 8.0.10 or higher")
} else if version.LT(semver.MustParse("8.2.0")) {
return xerrors.New("MongoDB version must be 8.2.0 or higher")
}

if r.Spec.GetTopology() != mdbv1.ClusterTopologySingleCluster {
Expand Down
Loading