Skip to content

Conversation

@Gacko
Copy link
Contributor

@Gacko Gacko commented Nov 28, 2025

What this PR does / why we need it:

In clusters with the OwnerReferencesPermissionEnforcement admission controller enabled, the KubeadmControlPlane Controller Manager fails to update the owner references of Secrets:

E1128 06:20:28.361646       1 controller.go:353] "Reconciler error" err="error in ensuring cluster certificates ownership: failed to set ownerReference: failed to patch Secret <namespace>/<cluster>-ca: secrets \"<cluster>-ca\" is forbidden: cannot set an ownerRef on a resource you can't delete: , <nil>" controller="kubeadmcontrolplane" controllerGroup="controlplane.cluster.x-k8s.io" controllerKind="KubeadmControlPlane" KubeadmControlPlane="<namespace>/<cluster>" namespace="<namespace>" name="<cluster>" reconcileID="8ebb9dfb-a5f7-40ae-ae13-a3b77fd1af5c"

/area provider/control-plane-kubeadm

@k8s-ci-robot
Copy link
Contributor

@Gacko: The label(s) area/area/provider/control-plane-kubeadm cannot be applied, because the repository doesn't have them.

In response to this:

What this PR does / why we need it:

In clusters with the OwnerReferencesPermissionEnforcement admission controller enabled, the KubeadmControlPlane Controller Manager fails to update the owner references of Secrets:

E1128 06:20:28.361646       1 controller.go:353] "Reconciler error" err="error in ensuring cluster certificates ownership: failed to set ownerReference: failed to patch Secret <namespace>/<cluster>-ca: secrets \"<cluster>-ca\" is forbidden: cannot set an ownerRef on a resource you can't delete: , <nil>" controller="kubeadmcontrolplane" controllerGroup="controlplane.cluster.x-k8s.io" controllerKind="KubeadmControlPlane" KubeadmControlPlane="<namespace>/<cluster>" namespace="<namespace>" name="<cluster>" reconcileID="8ebb9dfb-a5f7-40ae-ae13-a3b77fd1af5c"

/area area/provider/control-plane-kubeadm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/needs-area PR is missing an area label label Nov 28, 2025
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/provider/control-plane-kubeadm Issues or PRs related to KCP and removed do-not-merge/needs-area PR is missing an area label labels Nov 28, 2025

// +kubebuilder:rbac:groups=core,resources=events,verbs=create;patch
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this only be on finalizers (as done this CAPA PR example)?

Copy link
Contributor

Choose a reason for hiding this comment

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

ensureCertificatesOwnerRef indeed sets the owner reference and therefore seems to need delete permission as of https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#ownerreferencespermissionenforcement – @Gacko and me clarified this in chat. Excerpt from the docs:

This admission controller protects the access to the metadata.ownerReferences of an object so that only users with delete permission to the object can change it. This admission controller also protects the access to metadata.ownerReferences[x].blockOwnerDeletion of an object, so that only users with update permission to the finalizers subresource of the referenced owner can change it.

Leaving this comment here for others reviewers as reference.

@AndiDog
Copy link
Contributor

AndiDog commented Nov 28, 2025

LGTM

@Gacko
Copy link
Contributor Author

Gacko commented Nov 30, 2025

/retest

@fabriziopandini
Copy link
Member

@Gacko thanks for this PR!
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 2, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 77e4048773bb0f8628cf6c35469942edc5ae77e4

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 2, 2025
@fabriziopandini
Copy link
Member

/cherry-pick release-1.12

@k8s-infra-cherrypick-robot

@fabriziopandini: once the present PR merges, I will cherry-pick it on top of release-1.12 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.12

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot merged commit 5793ee7 into kubernetes-sigs:main Dec 2, 2025
18 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.13 milestone Dec 2, 2025
@k8s-infra-cherrypick-robot

@fabriziopandini: new pull request created: #13097

In response to this:

/cherry-pick release-1.12

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/control-plane-kubeadm Issues or PRs related to KCP cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants