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

enhance handling prune for CR #214

Merged
merged 1 commit into from
Apr 13, 2022

Conversation

xuzhenglun
Copy link
Contributor

@xuzhenglun xuzhenglun commented Mar 28, 2022

What this PR does / why we need it:

  1. allow CR to decide whether to enable pruning resources;
  2. allow CR to decide what kinds of resources should be pruned.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

introduce 2 interfaces to let CR can decide whether and how to prune resources. When none of them are implemented, the behavior should be the same as before. So I think this is not a breaking change.

Additional documentation:

@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 Mar 28, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @xuzhenglun. 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 sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Mar 28, 2022
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 28, 2022
@xuzhenglun
Copy link
Contributor Author

ping @atoato88

This PR enhances the ability of prune, and it doesn't relate with DirectApplier. I would be very grateful if you could take a look at this PR.

@atoato88
Copy link
Contributor

atoato88 commented Apr 5, 2022

I agree with this PR's enhancement about prune-whitelist.

I think kubebuilder-declarative-pattern has similar functions by WithApplyPrune already.
I think this framework chosed implement With*** functions for manipurating, so it's prefer to update WithApplyPrune or add new With*** functions if you would like to enhance prune functionality.
e.g. implement new WithPruneWhitelist?
WDYT?

@xuzhenglun
Copy link
Contributor Author

xuzhenglun commented Apr 6, 2022

agree

With*** function works just fine when we want to build a specific addon operator. However, I'm trying to implement a generic AddonManager for Cluster. My user could choose to enable pruning by setting a flag in CR. Furthermore, consisting of Addon could have CRD inside, so they should be able to configure the white list to determine what kind of resource could be pruned.

To achieve the above by using the WithPrune function, It's necessary to pass CR to the user's function, and it will change the function signature of WithPrune which can be a breaking change. Secondly, framework users still need to implement methods like Prune or PruneWhiteList anyway, because those configurations are defined in CR.

WDYT?

@@ -74,6 +74,14 @@ type DeclarativeObject interface {
metav1.Object
}

type Pruner interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add some explaination for this interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An explanation of the interface has been appended.

Prune() bool
}

type PruneWhiteLister interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto.

Copy link
Contributor

Choose a reason for hiding this comment

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

And, []string has specific format for gvk?
If so, please wirte that.

Copy link
Contributor

Choose a reason for hiding this comment

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

perfect! 😄

@atoato88
Copy link
Contributor

atoato88 commented Apr 7, 2022

Thank you to explain the context detailed.
I agree with your thinking, I think it's preferable for achieve your requirements.

BTW, I left review comments above, please check those.

@xuzhenglun
Copy link
Contributor Author

Thank you to explain the context detailed. I agree with your thinking, I think it's preferable for achieve your requirements.

BTW, I left review comments above, please check those.

Thanks for your review. I append some comments in the source code and just updated this PR.

@atoato88
Copy link
Contributor

/approve
Thank you to update quickly!

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 12, 2022
@atoato88
Copy link
Contributor

/approve cancel
oh, we should check test before approving.

@k8s-ci-robot k8s-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 12, 2022
@atoato88
Copy link
Contributor

/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 12, 2022
@atoato88
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: atoato88, xuzhenglun

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 Apr 12, 2022
@xuzhenglun
Copy link
Contributor Author

@atoato88 still needs an LGTM label to merge. Is something I need to do yet?

@atoato88
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 13, 2022
@k8s-ci-robot k8s-ci-robot merged commit 24a86e3 into kubernetes-sigs:master Apr 13, 2022
@xuzhenglun xuzhenglun deleted the feature/prune branch April 14, 2022 09:47
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. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants