Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Changed default excluded labels from hardcoded values to be provided as CLI args, fixed incorrect exclusion bypass with annotation #293

Conversation

dedri-github
Copy link
Contributor

@dedri-github dedri-github commented May 31, 2023

As discussed in #276, currently resources which are created by Rancher (and have the cattle.io/creator=norman label) are being excluded by default, without any way to disable this behavior. In addition, there a bug that causes resources with the propagate.hnc.x-k8s.io/all annotation to be propagated even though they are excluded.

This PR changes the exclude mechanism to rely on a CLI argument to the manager instead of a hardcoded value. It also sets the default arguments of the manager to have the cattle.io/creator=norman excluded by default, to keep the same default behavior as before. Documentation is updated to reflect the change. In addition, the bug that caused excluded resources to be propagated when using the propagate.hnc.x-k8s.io/all is fixed.

Edit: force-pushed an update that also fixes the bug that was mentioned in the issue.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 31, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot requested review from rjbez17 and srampal May 31, 2023 14:55
@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not 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 31, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @duduedri96. 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 31, 2023
@dedri-github
Copy link
Contributor Author

/check-cla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 31, 2023
@dedri-github dedri-github force-pushed the dev/excluded-labels-cli-args branch from 8202889 to c31b955 Compare May 31, 2023 20:46
@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 May 31, 2023
@dedri-github dedri-github force-pushed the dev/excluded-labels-cli-args branch from c31b955 to 7c63faf Compare June 2, 2023 08:29
@dedri-github
Copy link
Contributor Author

dedri-github commented Jun 2, 2023

Note: force-pushed an update that also fixes the bug that was mentioned in the GitHub issue.
Ready to be reviewed.
Thanks!

@dedri-github dedri-github force-pushed the dev/excluded-labels-cli-args branch from 7c63faf to 4224e86 Compare June 2, 2023 08:36
@dedri-github dedri-github changed the title Changed default excluded labels from hardcoded values to be provided as CLI args Changed default excluded labels from hardcoded values to be provided as CLI args, fixed incorrect exclusion bypass with annotation Jun 2, 2023
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

Great change! Just a few comments, mainly aesthetic but one functional.

@dedri-github
Copy link
Contributor Author

Thanks @adrianludwin ! Will work on that during the next weekend.

@dedri-github dedri-github force-pushed the dev/excluded-labels-cli-args branch from 4224e86 to bdee4bd Compare June 10, 2023 18:35
@dedri-github
Copy link
Contributor Author

@adrianludwin , I made the changes you requested, can you please re-review?

About the behavior change, I left it as-is and replied on your comment above with my thoughts, and I'm not sure what to do further.
Thanks!

@dedri-github dedri-github force-pushed the dev/excluded-labels-cli-args branch from bdee4bd to 31405af Compare June 10, 2023 18:44
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 10, 2023
@rjbez17
Copy link
Contributor

rjbez17 commented Jun 11, 2023

/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 Jun 11, 2023
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

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

lgtm after a few final changes, thanks!

Comment on lines 959 to 967
* `--nopropagation-label`: has the same effect as the `propagate.hnc.x-k8s.io/none`
annotation as specified in [limiting propagation](how-to.md#limit-the-propagation-of-an-object-to-descendant-namespaces),
but is useful when there's no control over what annotations the object has in order
to disable the propagation of that object. This argument may be specified multiple times,
with each parameter representing one `key=val` pair of a label that should exclude an object
from propagation.
* Rancher objects that have the label `cattle.io/creator=norman` are not propagated by
default (refer to [Concepts: built in exceptions](concepts.md#built-in-exceptions) for more
information).
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please fix the indentation to match what's above it? Thanks!

with each parameter representing one `key=val` pair of a label that should exclude an object
from propagation.
* Rancher objects that have the label `cattle.io/creator=norman` are not propagated by
default (refer to [Concepts: built in exceptions](concepts.md#built-in-exceptions) for more
Copy link
Contributor

Choose a reason for hiding this comment

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

"by default" -> "by the default manifests"

Changed default exclusion by label mechanism to use this CLI argument instead of a hardcoded list of labels. Moved the default Rancher label exclusion to be a default CLI argument on the manager. Fixed a bug that caused excluded resources to be propagated with the propagate.hnc.x-k8s.io/all annotation.

Tested: made sure the current test for default exclusion fails after my
CLI argument change, changed the test to reflect the changes, test now passes as
expected. Wrote a test that verifies the propagate.hnc.x-k8s.io/all annotation bug
doesn't occur, which failed before the bugfix. Executed e2e tests and they pass.
Manually tested the manager by adding the new CLI argument and with that a labeled
resource was skipped, then removed the argument and it has propagated. Did the same
with two different annotations specified together as two CLI arguments, and resources that
had any of those labels were skipped as expected. Manually tried to cause an
excluded resource to propagate by adding the propagate.hnc.x-k8s.io/all
annotation, and it didn't propagate.
@dedri-github dedri-github force-pushed the dev/excluded-labels-cli-args branch from 31405af to 75518d5 Compare June 11, 2023 18:19
@dedri-github
Copy link
Contributor Author

@adrianludwin , implemented your suggestions.
Once you set lgtm, should I assign tashimi for approval (as the ci-robot suggested) or you'll approve?

Thank you!

@adrianludwin
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 12, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianludwin, duduedri96

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 12, 2023
@adrianludwin
Copy link
Contributor

@duduedri96 thanks for this change! Can you please cherry-pick it into the v1.1 branch as well? Then I'll release v1.1 RC2 for testing.

@k8s-ci-robot k8s-ci-robot merged commit b27aecb into kubernetes-retired:master Jun 12, 2023
@dedri-github
Copy link
Contributor Author

Thanks @adrianludwin , created #299 cherry pick PR.

@adrianludwin adrianludwin added this to the release-v1.1 milestone Jun 12, 2023
k8s-ci-robot added a commit that referenced this pull request Jun 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants