-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
🌱 Add function RemoveControllerReference and HasControllerReference #2509
🌱 Add function RemoveControllerReference and HasControllerReference #2509
Conversation
6c99348
to
b4f0d66
Compare
…controllerutil Signed-off-by: Troy Connor <troy0820@users.noreply.github.com>
b4f0d66
to
da41833
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, troy0820 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 |
|
||
// RemoveControllerReference removes an owner reference where the controller | ||
// equals true | ||
func RemoveControllerReference(owner, object metav1.Object, scheme *runtime.Scheme) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@troy0820 Sorry for the late review :).
I'm not sure if this func works as intended. It first checks if there is a controller ownerRef on the object and then it removes the passed in owner. It doesn't check that the passed in owner is actually the controller (which I think is the goal of this func)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now looking at it, I’m not sure how I missed that. I’ll update the func to look if the owner is the controlled and remove that reference, otherwise it misses the goal as you said.
I’ll create an issue and assign it to me.
RemoveControllerReference
to controllerutilHasControllerReference
to controllerutilWhen creating #2462 it was discussed that to achieve the ask of the issue #2381 two functions can help remove ControllerReferences to get around the errors of it not being able to be overwritten.
These two functions (and not to be confused with the original PR that allows removal of any owner reference), allows the caller to see if the owner reference they want to remove in fact is a "ControllerReference" (controller = true)
This functionality is present with finalizers and will be helpful when trying to mitigate issues with trying to overwrite the owner reference on an object.