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

✨Finalizer helper library #1481

Merged

Conversation

rashmigottipati
Copy link
Contributor

@rashmigottipati rashmigottipati commented Apr 19, 2021

Closes #1453
PR for adding a finalizer helper library to controller-runtime

Signed-off-by: rashmigottipati chowdary.grashmi@gmail.com

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

Hi @rashmigottipati. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 19, 2021
pkg/finalizer/finalizer.go Outdated Show resolved Hide resolved
pkg/finalizer/finalizer.go Outdated Show resolved Hide resolved
@joelanford
Copy link
Member

/ok-to-test

@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 Apr 20, 2021
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 20, 2021
@rashmigottipati rashmigottipati force-pushed the finalizer-library branch 4 times, most recently from 1736ee3 to eb23655 Compare April 20, 2021 19:24
@rashmigottipati rashmigottipati changed the title ✨[WIP] Finalizer helper library ✨Finalizer helper library Apr 20, 2021
@rashmigottipati rashmigottipati force-pushed the finalizer-library branch 2 times, most recently from 9ae1fd8 to e362644 Compare April 21, 2021 06:10
@rashmigottipati
Copy link
Contributor Author

/cc @estroz @jmrodri

@k8s-ci-robot
Copy link
Contributor

@rashmigottipati: GitHub didn't allow me to request PR reviews from the following users: jmrodri.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @estroz @jmrodri

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.

pkg/finalizer/finalizer.go Outdated Show resolved Hide resolved
pkg/finalizer/finalizer.go Outdated Show resolved Hide resolved
pkg/finalizer/finalizer.go Outdated Show resolved Hide resolved
pkg/finalizer/types.go Outdated Show resolved Hide resolved
pkg/finalizer/finalizer.go Outdated Show resolved Hide resolved
@rashmigottipati
Copy link
Contributor Author

@joelanford thanks for the review! Addressed the latest set of comments. Could you please take another look?

@joelanford
Copy link
Member

I think the last question I have is whether we want to split the needsUpdate value in two: needsUpdate and needsStatusUpdate.

Without that, callers using CRDs with the status subresource will likely need to call both client.Update() and client.Status().Update()

On the otherhand, an API with three return values starts to get into "is this the right API?" territory.

@estroz
Copy link
Contributor

estroz commented May 21, 2021

@joelanford I agree; something like OperationResult would be useful here.

@joelanford
Copy link
Member

joelanford commented May 22, 2021

+1 @estroz. Are you thinking of using that directly or adding a separate type in the finalizer package that conveys just what a finalizer would need? I vote the latter.

If you agree, I think there's two options for how to do this:

type Result struct {
   Updated bool
   StatusUpdated bool
}

or

type Result string

const (
	ResultUnchanged     Result = "unchanged"
	ResultUpdated       Result = "updated"
	ResultUpdatedStatus Result = "updatedStatus"
    ResultUpdatedAll    Result = "updatedAll"
)

I think I prefer the result struct rather than the result string, since it seems easier to use in conditional expressions that drive the client update calls.

@estroz
Copy link
Contributor

estroz commented May 24, 2021

A new type for sure, and I'm fine with the struct approach (pretty similar to Option<T> return types in functional languages that get pattern-matched).

Signed-off-by: rashmigottipati <chowdary.grashmi@gmail.com>
Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>
Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>
…ions

Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>
Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>
Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>
pkg/finalizer/finalizer.go Outdated Show resolved Hide resolved
Signed-off-by: Rashmi Gottipati <chowdary.grashmi@gmail.com>
@rashmigottipati
Copy link
Contributor Author

/test pull-controller-runtime-test-master

Copy link
Contributor

@estroz estroz 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 Jun 7, 2021
@joelanford
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: estroz, joelanford, rashmigottipati

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 Jun 8, 2021
@k8s-ci-robot k8s-ci-robot merged commit 750cf33 into kubernetes-sigs:master Jun 8, 2021
@k8s-ci-robot k8s-ci-robot added this to the v0.9.x milestone Jun 8, 2021
@alvaroaleman
Copy link
Member

@estroz @joelanford Can we in the future please either tell our contributors to squash their commits or use the label to have them squashed on merge? Something like this clutters the git history bigtimes for no good reason.

@estroz
Copy link
Contributor

estroz commented Jun 10, 2021

@alvaroaleman yes, a worthwhile callout.

@rashmigottipati
Copy link
Contributor Author

@alvaroaleman, my bad I didn't realize that the PR would get automatically merged after it's approved. Will be mindful of that going forward. Thanks for mentioning it.

@joelanford
Copy link
Member

My bad! Perhaps we should configure the merge bot to squash by default? I feel like I'm guilty of approving several PRs without using the label or asking for a squash because I'm used to other projects where that happens automatically.

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/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.

[Feature Request] Finalizer helper library
9 participants