-
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
⚠️ Use controllerutil.Object for event handling #1118
⚠️ Use controllerutil.Object for event handling #1118
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman 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 |
1debd44
to
38d77dd
Compare
@alvaroaleman: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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/test-infra repository. I understand the commands that are listed here. |
// Object is the object from the event | ||
Object runtime.Object | ||
Object controllerutil.Object |
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.
Sidenote: Should we move this Object interface somewhere else?
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.
What do you think having it under reconcile.Object
?
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.
I think pretty much all places we have are subpar and this should be in upstream somewhere. We can still move it around freely later and then alias it.
If possible I would like to keep that discussion out of this PR :)
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.
Well, while I agree that there needs to be a better place to have this interface, it feels weird that we're now using an util
package throughout our codebase. We might also get into circular dependencies if at any point controllerutil needs to use a symbol from one of the packages that now uses this interface
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.
Yeah but solving this now is premature optimization. If we actually get that problem, we can still move the definition elsewhere and make controllerutil.Object
an alias.
I guess my point here is mostly that I think that discussion is outside of the scope of this PR.
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.
I guess my point here is mostly that I think that discussion is outside of the scope of this PR.
+1, was brainstorming to follow-up with another PR later, mostly wanted to agree on something and change it before we cut v0.7.0
/milestone v0.7.x |
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.
/lgtm
Prep code for supporting k8s 1.21: * Add context.Context parameter to Reconcile() functions [1] * Add RBAC get/create/update coordination.k8s.io/v1 Leases (replacing a configmap for leader election locks) [2] * Adapt event handler code to reflect simplification [3] * Adapt to apimachinery/pkg/runtime Log deprecation (replaced with pkg/client Log) [4] * client.Object is preferred in favor of runtime.Object (v0.7.0 release) [5] * Use admission/v1 instead of v1beta1 for webhook requests [6] [1] - kubernetes-sigs/controller-runtime#1054 [2] - kubernetes-sigs/controller-runtime#1144 [3] - kubernetes-sigs/controller-runtime#1119 [4] - kubernetes-sigs/controller-runtime#1105 [5] - kubernetes-sigs/controller-runtime#898 kubernetes-sigs/controller-runtime#1118 [6] - kubernetes-sigs/controller-runtime#1284 kubernetes-sigs/controller-runtime@a32b29d Signed-off-by: Angel Misevski <[email protected]>
Prep code for supporting k8s 1.21: * Add context.Context parameter to Reconcile() functions [1] * Add RBAC get/create/update coordination.k8s.io/v1 Leases (replacing a configmap for leader election locks) [2] * Adapt event handler code to reflect simplification [3] * Adapt to apimachinery/pkg/runtime Log deprecation (replaced with pkg/client Log) [4] * client.Object is preferred in favor of runtime.Object (v0.7.0 release) [5] * Use admission/v1 instead of v1beta1 for webhook requests [6] [1] - kubernetes-sigs/controller-runtime#1054 [2] - kubernetes-sigs/controller-runtime#1144 [3] - kubernetes-sigs/controller-runtime#1119 [4] - kubernetes-sigs/controller-runtime#1105 [5] - kubernetes-sigs/controller-runtime#898 kubernetes-sigs/controller-runtime#1118 [6] - kubernetes-sigs/controller-runtime#1284 kubernetes-sigs/controller-runtime@a32b29d Signed-off-by: Angel Misevski <[email protected]>
Prep code for supporting k8s 1.21: * Add context.Context parameter to Reconcile() functions [1] * Add RBAC get/create/update coordination.k8s.io/v1 Leases (replacing a configmap for leader election locks) [2] * Adapt event handler code to reflect simplification [3] * Adapt to apimachinery/pkg/runtime Log deprecation (replaced with pkg/client Log) [4] * client.Object is preferred in favor of runtime.Object (v0.7.0 release) [5] * Use admission/v1 instead of v1beta1 for webhook requests [6] [1] - kubernetes-sigs/controller-runtime#1054 [2] - kubernetes-sigs/controller-runtime#1144 [3] - kubernetes-sigs/controller-runtime#1119 [4] - kubernetes-sigs/controller-runtime#1105 [5] - kubernetes-sigs/controller-runtime#898 kubernetes-sigs/controller-runtime#1118 [6] - kubernetes-sigs/controller-runtime#1284 kubernetes-sigs/controller-runtime@a32b29d Signed-off-by: Angel Misevski <[email protected]>
Prep code for supporting k8s 1.21: * Add context.Context parameter to Reconcile() functions [1] * Add RBAC get/create/update coordination.k8s.io/v1 Leases (replacing a configmap for leader election locks) [2] * Adapt event handler code to reflect simplification [3] * Adapt to apimachinery/pkg/runtime Log deprecation (replaced with pkg/client Log) [4] * client.Object is preferred in favor of runtime.Object (v0.7.0 release) [5] * Use admission/v1 instead of v1beta1 for webhook requests [6] [1] - kubernetes-sigs/controller-runtime#1054 [2] - kubernetes-sigs/controller-runtime#1144 [3] - kubernetes-sigs/controller-runtime#1119 [4] - kubernetes-sigs/controller-runtime#1105 [5] - kubernetes-sigs/controller-runtime#898 kubernetes-sigs/controller-runtime#1118 [6] - kubernetes-sigs/controller-runtime#1284 kubernetes-sigs/controller-runtime@a32b29d Signed-off-by: Angel Misevski <[email protected]>
Prep code for supporting k8s 1.21: * Add context.Context parameter to Reconcile() functions [1] * Add RBAC get/create/update coordination.k8s.io/v1 Leases (replacing a configmap for leader election locks) [2] * Adapt event handler code to reflect simplification [3] * Adapt to apimachinery/pkg/runtime Log deprecation (replaced with pkg/client Log) [4] * client.Object is preferred in favor of runtime.Object (v0.7.0 release) [5] * Use admission/v1 instead of v1beta1 for webhook requests [6] [1] - kubernetes-sigs/controller-runtime#1054 [2] - kubernetes-sigs/controller-runtime#1144 [3] - kubernetes-sigs/controller-runtime#1119 [4] - kubernetes-sigs/controller-runtime#1105 [5] - kubernetes-sigs/controller-runtime#898 kubernetes-sigs/controller-runtime#1118 [6] - kubernetes-sigs/controller-runtime#1284 kubernetes-sigs/controller-runtime@a32b29d Signed-off-by: Angel Misevski <[email protected]>
Prep code for supporting k8s 1.21: * Add context.Context parameter to Reconcile() functions [1] * Add RBAC get/create/update coordination.k8s.io/v1 Leases (replacing a configmap for leader election locks) [2] * Adapt event handler code to reflect simplification [3] * Adapt to apimachinery/pkg/runtime Log deprecation (replaced with pkg/client Log) [4] * client.Object is preferred in favor of runtime.Object (v0.7.0 release) [5] * Use admission/v1 instead of v1beta1 for webhook requests [6] [1] - kubernetes-sigs/controller-runtime#1054 [2] - kubernetes-sigs/controller-runtime#1144 [3] - kubernetes-sigs/controller-runtime#1119 [4] - kubernetes-sigs/controller-runtime#1105 [5] - kubernetes-sigs/controller-runtime#898 kubernetes-sigs/controller-runtime#1118 [6] - kubernetes-sigs/controller-runtime#1284 kubernetes-sigs/controller-runtime@a32b29d Signed-off-by: Angel Misevski <[email protected]>
Prep code for supporting k8s 1.21: * Add context.Context parameter to Reconcile() functions [1] * Add RBAC get/create/update coordination.k8s.io/v1 Leases (replacing a configmap for leader election locks) [2] * Adapt event handler code to reflect simplification [3] * Adapt to apimachinery/pkg/runtime Log deprecation (replaced with pkg/client Log) [4] * client.Object is preferred in favor of runtime.Object (v0.7.0 release) [5] * Use admission/v1 instead of v1beta1 for webhook requests [6] [1] - kubernetes-sigs/controller-runtime#1054 [2] - kubernetes-sigs/controller-runtime#1144 [3] - kubernetes-sigs/controller-runtime#1119 [4] - kubernetes-sigs/controller-runtime#1105 [5] - kubernetes-sigs/controller-runtime#898 kubernetes-sigs/controller-runtime#1118 [6] - kubernetes-sigs/controller-runtime#1284 kubernetes-sigs/controller-runtime@a32b29d Signed-off-by: Angel Misevski <[email protected]>
Prep code for supporting k8s 1.21: * Add context.Context parameter to Reconcile() functions [1] * Add RBAC get/create/update coordination.k8s.io/v1 Leases (replacing a configmap for leader election locks) [2] * Adapt event handler code to reflect simplification [3] * Adapt to apimachinery/pkg/runtime Log deprecation (replaced with pkg/client Log) [4] * client.Object is preferred in favor of runtime.Object (v0.7.0 release) [5] * Use admission/v1 instead of v1beta1 for webhook requests [6] [1] - kubernetes-sigs/controller-runtime#1054 [2] - kubernetes-sigs/controller-runtime#1144 [3] - kubernetes-sigs/controller-runtime#1119 [4] - kubernetes-sigs/controller-runtime#1105 [5] - kubernetes-sigs/controller-runtime#898 kubernetes-sigs/controller-runtime#1118 [6] - kubernetes-sigs/controller-runtime#1284 kubernetes-sigs/controller-runtime@a32b29d Signed-off-by: Angel Misevski <[email protected]>
This change makes it significantly easier to interact with the various functions in the handling stack by using
controllerutil.Object
for events rather thanruntime.Object + metav1.Object
in dedicated fields.