Repository navigation
fix(plugin): handle a missing exec permission in status - #11687
Merged
Merged
Conversation
Contributor
|
❗ By default, the pull request is configured to backport to all release branches.
|
armru
approved these changes
Oct 19, 2026
mnencia
force-pushed
the
dev/status-size-forbidden
branch
from
October 19, 2026 16:35
38d8aa9 to
0080ac0
Compare
mnencia
force-pushed
the
dev/status-size-forbidden
branch
from
October 19, 2026 16:37
0080ac0 to
5c48d75
Compare
mnencia
approved these changes
Oct 19, 2026
Member
|
/ok-to-merge tested locally on kind with a read-only user: size and |
mnencia
force-pushed
the
dev/status-size-forbidden
branch
from
October 19, 2026 16:54
5c48d75 to
bc7982c
Compare
`kubectl cnpg status` computes the cluster size with `du`, which needs the `pods/exec` permission. Without it, the raw exec error was printed on the `Size` line. Check the permission first and show that it is not permitted instead. Assisted-by: Claude Relates #11519 Signed-off-by: Gabriele Bartolini <[email protected]>
When no Pod holds the primary role, as during bootstrap or a failover, the access review had no namespace and was evaluated at cluster scope. A user allowed to exec only in the Cluster namespace was told that the `pods/exec` permission was missing. There is no Pod to run `du` in, so skip the check in that case and report the size error as before. Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Marco Nenciarini <[email protected]>
With `--verbose`, `kubectl cnpg status` reads the PostgreSQL configuration through exec. Without the `pods/exec` permission it printed the raw errors and empty sections. Reuse the permission check and show that it is not permitted. Signed-off-by: Marco Nenciarini <[email protected]>
Signed-off-by: Marco Nenciarini <[email protected]>
Signed-off-by: Marco Nenciarini <[email protected]>
gbartolini
force-pushed
the
dev/status-size-forbidden
branch
from
October 20, 2026 06:41
bc7982c to
6ba68b6
Compare
mnencia
added a commit
that referenced
this pull request
Oct 20, 2026
`kubectl cnpg status` runs commands in the primary Pod through exec: `du` for the cluster size and, with `-v -v`, `cat` to read `custom.conf` and `pg_hba.conf`. Without the `pods/exec` permission, it printed raw exec errors, and the configuration sections made the command fail. Check permissions first with a `SelfSubjectAccessReview` on the primary Pod, and show `not permitted: requires the pods/exec permission` in place of the size and configuration sections. If the review itself fails, run the command anyway and report the actual error. When no Pod holds the primary role, as during bootstrap or a failover, skip the check, because the review would have no namespace and be evaluated at cluster scope. Mark `pods/exec` as optional for `status` in the kubectl plugin documentation. Assisted-by: Claude References #11519 Signed-off-by: Gabriele Bartolini <[email protected]> Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Marco Nenciarini <[email protected]> Co-authored-by: Armando Ruocco <[email protected]> Co-authored-by: Marco Nenciarini <[email protected]> (cherry picked from commit 69dab5d) Signed-off-by: Marco Nenciarini <[email protected]>
mnencia
added a commit
that referenced
this pull request
Oct 20, 2026
`kubectl cnpg status` runs commands in the primary Pod through exec: `du` for the cluster size and, with `-v -v`, `cat` to read `custom.conf` and `pg_hba.conf`. Without the `pods/exec` permission, it printed raw exec errors, and the configuration sections made the command fail. Check permissions first with a `SelfSubjectAccessReview` on the primary Pod, and show `not permitted: requires the pods/exec permission` in place of the size and configuration sections. If the review itself fails, run the command anyway and report the actual error. When no Pod holds the primary role, as during bootstrap or a failover, skip the check, because the review would have no namespace and be evaluated at cluster scope. Mark `pods/exec` as optional for `status` in the kubectl plugin documentation. Assisted-by: Claude References #11519 Signed-off-by: Gabriele Bartolini <[email protected]> Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Marco Nenciarini <[email protected]> Co-authored-by: Armando Ruocco <[email protected]> Co-authored-by: Marco Nenciarini <[email protected]> (cherry picked from commit 69dab5d) Signed-off-by: Marco Nenciarini <[email protected]>
leonardoce
pushed a commit
that referenced
this pull request
Oct 23, 2026
`kubectl auth can-i create pods/exec` reads `pods/exec` as the Pod named `exec`, so it checks `create` on Pods and answers `no` for the wrong reason: a user allowed to create Pods but not to exec gets `yes`, and a user allowed to port-forward gets `no` from the same form. Use `--subresource=exec` and say why. `kubectl cnpg psql` runs `kubectl exec` without the impersonation flags, and `kubectl cnpg report --logs` streams logs with a client built from the plain kubeconfig, so under `--as` both run with the caller's own identity and succeed even when the role forbids them. Warn against using them to try a role. The chart names its view role after its full name, which is `cnpg-cloudnative-pg-view` for a release named `cnpg`, not `<release>-view`. Its `rbac.aggregateClusterRoles` value also aggregates the chart's edit role into `edit` and `admin`, granting write access to CloudNativePG resources: say so where the value is recommended. Since #11687, `kubectl cnpg status` reports a missing `pods/exec` permission instead of failing those parts with an error: update the command table accordingly. Signed-off-by: Armando Ruocco <[email protected]>
leonardoce
pushed a commit
that referenced
this pull request
Oct 26, 2026
`kubectl auth can-i create pods/exec` reads `pods/exec` as the Pod named `exec`, so it checks `create` on Pods and answers `no` for the wrong reason: a user allowed to create Pods but not to exec gets `yes`, and a user allowed to port-forward gets `no` from the same form. Use `--subresource=exec` and say why. `kubectl cnpg psql` runs `kubectl exec` without the impersonation flags, and `kubectl cnpg report --logs` streams logs with a client built from the plain kubeconfig, so under `--as` both run with the caller's own identity and succeed even when the role forbids them. Warn against using them to try a role. The chart names its view role after its full name, which is `cnpg-cloudnative-pg-view` for a release named `cnpg`, not `<release>-view`. Its `rbac.aggregateClusterRoles` value also aggregates the chart's edit role into `edit` and `admin`, granting write access to CloudNativePG resources: say so where the value is recommended. Since #11687, `kubectl cnpg status` reports a missing `pods/exec` permission instead of failing those parts with an error: update the command table accordingly. Signed-off-by: Armando Ruocco <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
kubectl cnpg statusruns commands in the primary Pod through exec:dufor the cluster size and, with-v -v,catto readcustom.confandpg_hba.conf. Without thepods/execpermission, it printed raw exec errors, and the configuration sections made the command fail.Check permissions first with a
SelfSubjectAccessReviewon the primary Pod, and shownot permitted: requires the pods/exec permissionin place of the size and configuration sections. If the review itself fails, run the command anyway and report the actual error. When no Pod holds the primary role, as during bootstrap or a failover, skip the check, because the review would have no namespace and be evaluated at cluster scope.Mark
pods/execas optional forstatusin the kubectl plugin documentation.Assisted-by: Claude
References #11519