Skip to content

Conversation

@lsierant
Copy link
Contributor

@lsierant lsierant commented Oct 25, 2025

Summary

This PR fixes a problem which was preventing creating cluster-wide mongodb custom roles.

Context
As described in MongoDB docs the resource object is either:

{ db: <database>, collection: <collection> }

or

{ cluster : true }

So that means we cannot provide empty strings for db and collection fields as empty string means "any db/collection".

At the same time our previous serialization rules were always sending empty strings even if not set. This was the source of the problem - it wasn't possible to specify cluster: true because the operator was also sending empty db and collections.

Backwards compatibility
Making db and collection fields just as omitempty *string is not sufficient, because that would change the semantics of the resource and would be potentially a breaking change. In order to preserve backwards compatibility we need additional logic (see normalizePrivilegeResource that will maintain the same behavior for non-cluster-wide resources (sending empty strings even if the field is not set in yaml).

Proof of Work

Tests passing.

Based on PR #551

Chain of upstream PRs as of 2025-10-25

@lsierant lsierant self-assigned this Oct 25, 2025
@lsierant lsierant force-pushed the lsierant/custom-roles-regression-tests branch from 43c0502 to 2d7b9a0 Compare October 27, 2025 14:46
@lsierant lsierant force-pushed the lsierant/custom-roles branch 2 times, most recently from cce9040 to 91233d8 Compare October 27, 2025 14:51
@lsierant lsierant force-pushed the lsierant/custom-roles-regression-tests branch from 2d7b9a0 to 3040210 Compare October 27, 2025 14:53
@lsierant lsierant force-pushed the lsierant/custom-roles branch from 91233d8 to d9c39b3 Compare October 27, 2025 15:45
@lsierant lsierant force-pushed the lsierant/custom-roles-regression-tests branch 2 times, most recently from 70c14e8 to c150032 Compare October 27, 2025 15:49
@lsierant lsierant force-pushed the lsierant/custom-roles branch from d9c39b3 to 0492502 Compare October 27, 2025 15:52
@lsierant lsierant marked this pull request as ready for review October 27, 2025 16:48
@lsierant lsierant requested review from a team and vinilage as code owners October 27, 2025 16:48
@lsierant lsierant requested review from anandsyncs, mircea-cosbuc and nammn and removed request for a team October 27, 2025 16:48
@lsierant lsierant force-pushed the lsierant/custom-roles-regression-tests branch from c150032 to 545dc80 Compare October 29, 2025 12:40
@lsierant lsierant force-pushed the lsierant/custom-roles branch from d3381a7 to 8fa7a1a Compare October 29, 2025 12:41
date: 2025-10-27
---

* Fixed a problem that prevented specifying cluster-wide privileges in database custom roles.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to change to: "Fixed inability to specify cluster-wide privileges in custom roles."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, thanks!

@lsierant lsierant force-pushed the lsierant/custom-roles-regression-tests branch from 545dc80 to 71cd46b Compare October 31, 2025 09:28
@lsierant lsierant force-pushed the lsierant/custom-roles branch from 4c3939d to f515880 Compare October 31, 2025 09:28
@lsierant lsierant requested a review from vinilage October 31, 2025 09:30
Copy link
Collaborator

@vinilage vinilage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT!

Comment on lines +1 to +6
---
kind: fix
date: 2025-10-27
---

* Fixed inability to specify cluster-wide privileges in custom roles.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@mircea-cosbuc mircea-cosbuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lsierant lsierant force-pushed the lsierant/custom-roles-regression-tests branch from 71cd46b to 724fa83 Compare November 3, 2025 08:39
@lsierant lsierant force-pushed the lsierant/custom-roles branch from f515880 to 3392469 Compare November 3, 2025 08:39
lsierant added a commit that referenced this pull request Nov 7, 2025
# Summary

This PR adds regression test for custom roles ensuring we will keep
backwards compatibility wrt handling empty strings vs omitted fields.

In the subsequent #553 the serialization rules for custom roles will be
changed.

## Proof of Work
Tests passing.
Base automatically changed from lsierant/custom-roles-regression-tests to master November 7, 2025 08:51
@lsierant lsierant force-pushed the lsierant/custom-roles branch from 3392469 to 7528541 Compare November 7, 2025 09:00
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

⚠️ (this preview might not be accurate if the PR is not rebased on current master branch)

MCK 1.6.0 Release Notes

New Features

  • MongoDBCommunity: Added support to configure custom cluster domain via newly introduced spec.clusterDomain resource field. If spec.clusterDomain is not set, environment variable CLUSTER_DOMAIN is used as cluster domain. If the environment variable CLUSTER_DOMAIN is also not set, operator falls back to cluster.local as default cluster domain.
  • Helm Chart: Introduced two new helm fields operator.podSecurityContext and operator.securityContext that can be used to configure securityContext for Operator deployment through Helm Chart.
  • MongoDBSearch: Switch to gRPC and mTLS for internal communication
    Since MCK 1.4 the mongod and mongot processess communicated using the MongoDB Wire Protocol and used keyfile authentication. This release switches that to gRPC with mTLS authentication. gRPC will allow for load-balancing search queries against multiple mongot processes in the future, and mTLS decouples the internal cluster authentication mode and credentials among mongod processes from the connection to the mongot process. The Operator will automatically enable gRPC for existing and new workloads, and will enable mTLS authentication if both Database Server and MongoDBSearch resource are configured for TLS.
  • MongoDBSearch: MongoDB deployments using X509 internal cluster authentication are now supported. Previously MongoDB Search required SCRAM authentication among members of a MongoDB replica set. Note: SCRAM client authentication is still required, this change merely relaxes the requirements on internal cluster authentication.
  • MongoDBSearch: Updated the default mongodb/mongodb-search image version to 0.55.0. This is the version MCK uses if .spec.version is not specified.

Bug Fixes

  • Fixed parsing of the customEnvVars Helm value when values contain = characters.
  • ReplicaSet: Blocked disabling TLS and changing member count simultaneously. These operations must now be applied separately to prevent configuration inconsistencies.
  • Fixed inability to specify cluster-wide privileges in custom roles.

Other Changes

  • 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.
  • kubectl-mongodb plugin: cosign, the signing tool that is used to sign kubectl-mongodb plugin binaries, has been updated to version 3.0.2. With this change, released binaries will be bundled with .bundle files containing both signature and certificate information. For more information on how to verify signatures using new cosign version please refer to -> https://github.com/sigstore/cosign/blob/v3.0.2/doc/cosign_verify-blob.md

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.

5 participants