Skip to content

fix: missing permissions when OwnerReferencesPermissionEnforcement admission controller is enabled #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NoOverflow
Copy link

@NoOverflow NoOverflow commented Jul 2, 2025

Barman plugin creates a role giving the rights for a managed CNPG cluster to interact with Barman-related resources (Objectstore, related secrets...).

func (r ReconcilerImplementation) ensureRole(
ctx context.Context,
cluster *cnpgv1.Cluster,
barmanObjects []barmancloudv1.ObjectStore,
) error {

In order for the role to be cleaned up automatically when the related cluster is deleted, an ownerReference is set on the role pointing to that cluster.

if err := setOwnerReference(cluster, newRole); err != nil {
return err
}

This causes an issue on all clusters with the OwnerReferencesPermissionEnforcement admission controller configured, and so by consequence all Openshift / OKD clusters which by default have it enabled.

This is due to the fact that this AdmCon. requires the ServiceAccount creating an object with an ownerReference to also have the rights to update the finalizers subresource of the referenced owner.

In our case, this means that the ServiceAccount used to create the role, must have the rights to update the finalizers field of a CNPG cluster object.

Fixes #425

@mnencia
Copy link
Member

mnencia commented Jul 3, 2025

The config/rbac/role.yaml file is created by controller-gen. I have committed a change to the internal/controller/objectstore_controller.go, which serves as the source.

@NoOverflow
Copy link
Author

The config/rbac/role.yaml file is created by controller-gen. I have committed a change to the internal/controller/objectstore_controller.go, which serves as the source.

Yeah I was pretty sure I was missing something and that those files weren't static. Thanks

NoOverflow and others added 2 commits July 9, 2025 14:27
@armru
Copy link
Member

armru commented Jul 11, 2025

@mnencia can we merge?

@mnencia
Copy link
Member

mnencia commented Jul 11, 2025

I think we can.

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.

cannot set blockOwnerDeletion if an ownerReference refers to a resource you can't set finalizers on
3 participants