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

kubectl apply: Deprecate --prune-whitelist in favor of --prune-allowlist #113116

Merged
merged 1 commit into from Nov 8, 2022

Conversation

brianpursley
Copy link
Member

@brianpursley brianpursley commented Oct 17, 2022

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Changes in kubectl apply --prune to support k8s Inclusive Naming Initiative:

  • Deprecated the --prune-whitelist flag.
  • Deprecated the PruneWhitelist field on ApplyFlags struct.
  • Removed PruneWhitelist field (not used anywhere) from ApplyOptions struct.
  • Added --prune-allowlist flag.
  • Added PruneAllowlist field on ApplyFlags struct.
  • Added unit tests for prune with allowlist

This commit also fixes a bug where the command would fail if you specified the same GVK multiple times for --allow-whitelist. Now it only attempts to prune the unique set of allowed GVKs.

Which issue(s) this PR fixes:

N/A

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Added a `--prune-allowlist` flag that can be used with `kubectl apply --prune`. This flag replaces and functions the same as the `--prune-whitelist` flag, which has been deprecated.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 17, 2022
@k8s-ci-robot
Copy link
Contributor

@brianpursley: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Oct 17, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brianpursley

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 area/kubectl approved Indicates a PR has been approved by an approver from all required OWNERS files. sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 17, 2022
@brianpursley
Copy link
Member Author

/hold
for review

@brianpursley
Copy link
Member Author

Questions:

  1. Is it OK to deprecate -AND- hide the flag at the same time, or will that confuse people?
  2. Assuming kubectl 1.29 is when the old flag can be removed (3 releases per year) if this makes it into 1.26. Is this correct?

@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 Oct 23, 2022
@KnVerey
Copy link
Contributor

KnVerey commented Nov 7, 2022

Thanks for adding all those tests!

By the way, the existing prune unit test (TestApplyPruneObjects) actually doesn't test prune at all. If you remove the line cmd.Flags().Set("prune", "true"), the test still passes! 😮

Looking at that test, I think it is completely redundant with the test above it. Digging through the history, it looks like it was introduced as a regression test in #85613, but it definitely does not cover that case either. It seems to me it would need at least two changes to cover that PR: it would need to apply non-namespaced objects exclusively and set expectations on tf.FakeDynamicClient instead of tf.UnstructuredClient asserting that the namespace specified in the flag is crawled. Out of scope for this PR though.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 7, 2022
@KnVerey
Copy link
Contributor

KnVerey commented Nov 8, 2022

@brianpursley I see this isn't auto-merging because you put a hold on it for review. Any further opinions you're looking for, or shall we remove that?

@brianpursley
Copy link
Member Author

@brianpursley I see this isn't auto-merging because you put a hold on it for review. Any further opinions you're looking for, or shall we remove that?

@KnVerey I put the hold so it would wait for a review and not auto-merge

/unhold

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Nov 8, 2022
Changes in kubectl apply --prune to support k8s Inclusive Naming Initiative:
* Deprecated the --prune-whitelist flag.
* Deprecated the PruneWhitelist field on ApplyFlags struct.
* Removed PruneWhitelist field (not used anywhere) from ApplyOptions struct.
* Added --prune-allowlist flag.
* Added PruneAllowlist field on ApplyFlags struct.
* Added unit tests for prune with allowlist

This commit also fixes a bug where the command would fail if you specified
the sameGVK multiple times for --allow-whitelist. Now it only attempts to
prune the unique set of allowed GVKs.
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 8, 2022
@brianpursley
Copy link
Member Author

Rebased

@pacoxu
Copy link
Member

pacoxu commented Nov 8, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2022
@pacoxu
Copy link
Member

pacoxu commented Nov 8, 2022

/test pull-kubernetes-e2e-kind-ipv6

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. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. 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

4 participants