@@ -647,7 +647,7 @@ func (r *ReconcilePerconaServerMongoDB) handleRsAddToShard(ctx context.Context,
647647}
648648
649649// handleReplsetInit initializes the replset within the first running pod's mongod container.
650- // This must be ran from within the running container to utilize the MongoDB Localhost Exception.
650+ // This must be run from within the running container to utilize the MongoDB Localhost Exception.
651651//
652652// See: https://www.mongodb.com/docs/manual/core/localhost-exception/
653653func (r * ReconcilePerconaServerMongoDB ) handleReplsetInit (ctx context.Context , cr * api.PerconaServerMongoDB , replset * api.ReplsetSpec , pods []corev1.Pod ) (* corev1.Pod , * api.ReplsetMemberStatus , error ) {
@@ -809,6 +809,12 @@ func getRoles(cr *api.PerconaServerMongoDB, role api.SystemUserRole) []mongo.Rol
809809 {DB : "admin" , Role : "directShardOperations" },
810810 }
811811 }
812+ case api .RoleUserAdmin :
813+ if cr .CompareVersion ("1.22.0" ) >= 0 {
814+ roles = []mongo.Role {
815+ {DB : "admin" , Role : "userAdminAnyDatabase" },
816+ }
817+ }
812818 }
813819 roles = append (roles , mongo.Role {DB : "admin" , Role : string (role )})
814820 return roles
@@ -1007,6 +1013,7 @@ func (r *ReconcilePerconaServerMongoDB) createOrUpdateSystemUsers(ctx context.Co
10071013 }
10081014
10091015 users := []api.SystemUserRole {api .RoleClusterAdmin , api .RoleClusterMonitor , api .RoleBackup , api .RoleDatabaseAdmin }
1016+ // When handleReplsetInit is not executed, e.g. when auth is disabled, the UserAdmin role should be created.
10101017 if cr .CompareVersion ("1.22.0" ) >= 0 {
10111018 users = append (users , api .RoleUserAdmin )
10121019 }
0 commit comments