Skip to content
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

Merged

Conversation

alvaroaleman
Copy link
Member

This change makes it significantly easier to interact with the various functions in the handling stack by using controllerutil.Object for events rather than runtime.Object + metav1.Object in dedicated fields.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 5, 2020
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 5, 2020
@alvaroaleman alvaroaleman changed the title :Warning: Use controllerutil.Object for event handling ⚠️ Use controllerutil.Object for event handling Aug 5, 2020
@k8s-ci-robot
Copy link
Contributor

@alvaroaleman: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-controller-runtime-apidiff-master 38d77dd link /test pull-controller-runtime-apidiff-master

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
Copy link
Member

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?

Copy link
Member

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?

Copy link
Member Author

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 :)

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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

@vincepri
Copy link
Member

vincepri commented Aug 6, 2020

/milestone v0.7.x

@k8s-ci-robot k8s-ci-robot added this to the v0.7.x milestone Aug 6, 2020
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 6, 2020
@k8s-ci-robot k8s-ci-robot merged commit 79da425 into kubernetes-sigs:master Aug 6, 2020
zcahana added a commit to zcahana/controller-runtime that referenced this pull request Nov 9, 2020
amisevsk added a commit to amisevsk/devworkspace-operator that referenced this pull request Aug 4, 2021
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 <amisevsk@redhat.com>
amisevsk added a commit to amisevsk/devworkspace-operator that referenced this pull request Aug 10, 2021
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 <amisevsk@redhat.com>
sleshchenko pushed a commit to amisevsk/devworkspace-operator that referenced this pull request Aug 11, 2021
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 <amisevsk@redhat.com>
amisevsk added a commit to amisevsk/devworkspace-operator that referenced this pull request Aug 12, 2021
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 <amisevsk@redhat.com>
amisevsk added a commit to amisevsk/devworkspace-operator that referenced this pull request Aug 12, 2021
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 <amisevsk@redhat.com>
amisevsk added a commit to amisevsk/devworkspace-operator that referenced this pull request Aug 12, 2021
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 <amisevsk@redhat.com>
JPinkney pushed a commit to devfile/devworkspace-operator that referenced this pull request Aug 30, 2021
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 <amisevsk@redhat.com>
sleshchenko pushed a commit to devfile/devworkspace-operator that referenced this pull request Sep 2, 2021
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 <amisevsk@redhat.com>
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. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants