Skip to content

LIB-876: Propagate custom users to shard replsets in sharded clusters#16

Merged
avinashtanniru merged 9 commits into
mainfrom
LIB-876-propagate-custom-users-to-shards
Jul 21, 2026
Merged

LIB-876: Propagate custom users to shard replsets in sharded clusters#16
avinashtanniru merged 9 commits into
mainfrom
LIB-876-propagate-custom-users-to-shards

Conversation

@avinashtanniru

Copy link
Copy Markdown

Summary

Fix for LIB-876 — custom users (like clusterSuperAdmin) cannot auth directly to shards in sharded clusters.

Problem

Custom users defined in spec.users are created via mongos (cluster level), but individual shard nodes maintain their own local admin databases. Direct-to-shard connections fail with auth errors.

Solution

After mongos user reconciliation, iterate each shard replset and call handleUsers() directly against each shard's primary.

Changes

  • pkg/controller/perconaservermongodb/custom_users.go: Add shard iteration loop
  • pkg/controller/perconaservermongodb/custom_users_test.go: New test TestReconcileCustomUsers_ShardedPropagation
  • pkg/version/version.txt: 1.22.0-31.22.0-4

Testing

All tests pass ✅

Custom users created via spec.users are created through mongos, which
stores them on the config server only. Individual shard replica sets
have no knowledge of these users, so direct-to-shard connections
(e.g. for clusterSuperAdmin) fail with auth errors.

Fix: after reconciling users via mongos, iterate over each shard replset
and call handleUsers() directly against each shard's primary. This mirrors
how system users (users.go) are propagated across all replsets via
mongoClientWithRole.

Roles are not re-applied to shards — role definitions only exist at the
cluster level (config server / mongos) and do not need to be replicated.

Bumps version to 1.22.0-4.
- Pin setup-envtest to v0.23.1 matching our controller-runtime version
  (latest moved to v0.24.1 requiring Go 1.26, CI has 1.25.1)
- Update deploy/operator.yaml and deploy/cw-operator.yaml image to
  perconalab/percona-server-mongodb-operator:main to match CI expectations
  from 'make manifests VERSION=main'
The @v0.23.1 tag doesn't contain the tools/setup-envtest package
as a separate module. Using @release-0.23 branch which is compatible
with Go 1.25.1 and contains the correct package structure.
…on change

LIB-982 disabled encryption at rest by default for community MongoDB
images. The test fixtures still contained --enableEncryption flags and
encryption key volume mounts. Regenerated all 9 fixtures to match
the current operator behavior.
Instead of creating all custom users on every shard, filter to only
propagate clusterSuperAdmin which needs direct shard access for
platform operations (compaction, backups, monitoring). Other custom
users remain cluster-level only and are accessed through mongos.
@avinashtanniru
avinashtanniru merged commit 1cd4c51 into main Jul 21, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants