Skip to content

Comments

[CLOUDP-339048] Fix a bug in regenerate_public_rbac_multi_cluster#670

Merged
viveksinghggits merged 2 commits intomasterfrom
fix-pub-rbac-mc
Jan 9, 2026
Merged

[CLOUDP-339048] Fix a bug in regenerate_public_rbac_multi_cluster#670
viveksinghggits merged 2 commits intomasterfrom
fix-pub-rbac-mc

Conversation

@viveksinghggits
Copy link
Collaborator

@viveksinghggits viveksinghggits commented Jan 2, 2026

Summary

This PR removes the buggy check that we had to generate multi-cluster. The statement if echo "${git_last_changed}" | grep -q -e 'cmd/kubectl-mongodb' -e 'pkg/kubectl-mongodb'; then was failing sometimes because of root cause mentioned below. But even if we apply the fix we didn't achieve a lot time wise, that's why as a solution we are removing the check and alway generating the RBAC.

Root cause

The function regenerate_public_rbac_multi_cluster from generate_files.sh was trying to list all the files from the git repo using the command

git_last_changed=$(git ls-tree -r origin/master --name-only)

and then it was trying to check if the kubectl plugin related files are in the listed files. And if that was the cases we re-generated the RBAC for multi-cluster.

if echo "${git_last_changed}" | grep -q -e 'cmd/kubectl-mongodb' -e 'pkg/kubectl-mongodb'; then
    echo 'regenerating multicluster RBAC public example'
    pushd pkg/kubectl-mongodb/common/
    EXPORT_RBAC_SAMPLES="true" go test ./... -run TestPrintingOutRolesServiceAccountsAndRoleBindings
...

But this has a small problem, since we are running git ls-tree the output of the command can become quite big at times, and because of that when we run echo "${git_last_changed}" and then use grep -q, we some times get unexpected result, i.e., even though the files cmd/kubectl-mongodb and/or pkg/kubectl-mongodb were present in the output of echo "${git_last_changed}", the output of the line echo 'regenerating multicluster RBAC public example' was not printed which resulted into the RBACs not getting generated.
The if statement behaved mysteriously because, if the size of git_last_changed is big, and the grep statement is satisfied, because of -q the grep statement will return and the pipe | will be closed but the echo is not done yet because of the size of git_last_changed and because of that it (echo ${git_last_changed}) will try to put more data to the pipe which will result into an error because the pipe is closed. This will result into if statement misbehaving.
https://biriukov.dev/docs/fd-pipe-session-terminal/2-pipes/#sigpipe-signal

To fix that we are not using -q anymore so that the pipe is not closed and SIGPIPE is not sent to echo, which would result into everything working fine.

Proof of Work

Manual test.

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you added changelog file?

@viveksinghggits viveksinghggits added the skip-changelog Use this label in Pull Request to not require new changelog entry file label Jan 2, 2026
@viveksinghggits viveksinghggits requested a review from a team as a code owner January 2, 2026 23:01
@viveksinghggits viveksinghggits changed the title Fix a bug in regenerate_public_rbac_multi_cluster [CLOUDP-339048] Fix a bug in regenerate_public_rbac_multi_cluster Jan 2, 2026
@github-actions
Copy link

github-actions bot commented Jan 2, 2026

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

MCK 1.6.2 Release Notes

Bug Fixes

  • Fixed an issue where monitoring agents would fail after disabling TLS on a MongoDB deployment.
  • Persistent Volume Claim resize fix: Fixed an issue where the Operator ignored namespaces when listing PVCs, causing conflicts with resizing PVCs of the same name. Now, PVCs are filtered by both name and namespace for accurate resizing.
  • Fixed a panic that occurred when the domain names for a horizon was empty. Now, if the domain names are not valid (RFC 1123), the validation will fail before reconciling.

@viveksinghggits viveksinghggits merged commit 7824ee7 into master Jan 9, 2026
14 of 15 checks passed
@viveksinghggits viveksinghggits deleted the fix-pub-rbac-mc branch January 9, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Use this label in Pull Request to not require new changelog entry file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants