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

✨ Migrate controllerutil AddFinalizer and RemoveFinalizer to controllerutil.Object and deprecate *WithError functions #962

Merged
merged 1 commit into from
May 25, 2020

Conversation

dmvolod
Copy link
Contributor

@dmvolod dmvolod commented May 23, 2020

As #898 introduces controllerutil.Object interface this fix migrates controllerutil AddFinalizer and RemoveFinalizer to the controllerutil.Object interface and remove *WithError functions as they are not needed anymore as checks are performing on the compile time.

Fixes #959

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 23, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @dmvolod. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 23, 2020
@dmvolod
Copy link
Contributor Author

dmvolod commented May 23, 2020

@alvaroaleman , as you suggested, I've opened a separate issue and PR which is migrating to the controllerutil.Object in RemoveFinalizer and AddFinalizer. Also removed *WithError as not needed anymore. Please have a look at this changes. Thank you.

@@ -248,19 +247,8 @@ func AddFinalizer(o metav1.Object, finalizer string) {
o.SetFinalizers(append(f, finalizer))
}

// AddFinalizerWithError tries to convert a runtime object to a metav1 object and add the provided finalizer.
Copy link
Member

Choose a reason for hiding this comment

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

hi @dmvolod I think it would be better for now to leave the WithError funcs and just add a comment that they are deprecated and shouldn't be used. We can remove them when we also merge other braking changes. AFAIK right now we do not have any breaking changes planned.

/ok-to-test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for feedback, @alvaroaleman
I've changed just common functions and marked *WithError as deprecated

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 23, 2020
@dmvolod dmvolod changed the title ✨ Migrate controllerutil AddFinalizer and RemoveFinalizer to controllerutil.Object and remove *WithError functions ✨ Migrate controllerutil AddFinalizer and RemoveFinalizer to controllerutil.Object and depercate *WithError functions May 24, 2020
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 24, 2020
@dmvolod dmvolod changed the title ✨ Migrate controllerutil AddFinalizer and RemoveFinalizer to controllerutil.Object and depercate *WithError functions ✨ Migrate controllerutil AddFinalizer and RemoveFinalizer to controllerutil.Object and deprecate *WithError functions May 24, 2020
Copy link
Member

@alvaroaleman alvaroaleman left a comment

Choose a reason for hiding this comment

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

/lgtm
/assign @vincepri

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 25, 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.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dmvolod, vincepri

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 May 25, 2020
@k8s-ci-robot k8s-ci-robot merged commit 4c7b43a into kubernetes-sigs:master May 25, 2020
boekkooi-fresh added a commit to boekkooi-fresh/controller-runtime that referenced this pull request Jul 30, 2020
In order to allow for a broader adoption of ContainsFinalizer, RemoveFinalizer and AddFinalizer and remove a BC break introduced to 0.5.x I switched the method back to the `metav1.Object`.

After reading kubernetes-sigs#959 and kubernetes-sigs#962 I'm unable to understand the benefit of requiring `runtime.Object` so I propose to revert the BC break and possible panic on line 285.
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
4 participants