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

Add MWH and update VWH on included-namespace label #39

Merged
merged 1 commit into from
May 20, 2021

Conversation

yiqigao217
Copy link
Contributor

@yiqigao217 yiqigao217 commented May 18, 2021

Part of #9.
Fixes #37.

Add mutating webhook to set the correct included-namespace label on
non-excluded namespaces if it's missing. Leave all other situation as is
and let the validating webhook to do the validation.

Update namespace validator to allow all other changes if the illegal
included-namespace label is unchanged. Since namespace mutator ensures
the label exists on included namespaces, update rules to ignore the case
when the label is missing on the included namespaces.

Add old instance field to the namespace validator. Decode it from
request to compare with the new instance. Add more test cases since we
now have more combination of cases to test.

Update the namespace tree label update logs and function name in the HC
reconciler to make it clear that the HC reconciler only updates the tree
labels and won't update included-namespace label if the MWH works fine.

Tested by make test with new test cases. Also tested manually by
applying namespace manifests with different labels, viewed the logs and
verified the MWH and VWH work fine.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 18, 2021
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 18, 2021
@k8s-ci-robot k8s-ci-robot requested review from srampal and tashimi May 18, 2021 18:55
@yiqigao217 yiqigao217 removed request for tashimi and srampal May 18, 2021 18:59
@yiqigao217
Copy link
Contributor Author

/assign @adrianludwin
/assign @rjbez17

cmd/manager/main.go Outdated Show resolved Hide resolved
config/webhook/manifests.yaml Outdated Show resolved Hide resolved
config/webhook/manifests.yaml Outdated Show resolved Hide resolved
internal/mutator/namespace_included_label.go Outdated Show resolved Hide resolved
internal/mutator/namespace_included_label.go Outdated Show resolved Hide resolved
internal/reconcilers/hierarchy_config.go Show resolved Hide resolved
internal/mutator/namespace_included_label.go Outdated Show resolved Hide resolved
@yiqigao217 yiqigao217 changed the title Replace included-namespace VWH rules with MWH Add MWH and update VWH on included-namespace label May 19, 2021
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 but with one

internal/validators/namespace.go Outdated Show resolved Hide resolved
internal/validators/namespace.go Outdated Show resolved Hide resolved
internal/validators/namespace.go Show resolved Hide resolved
Part of 9.
Fixes 37.

Add mutating webhook to set the correct `included-namespace` label on
non-excluded namespaces if it's missing. Leave all other situation as is
and let the validating webhook to do the validation.

Update namespace validator to allow all other changes if the illegal
included-namespace label is unchanged. Since namespace mutator ensures
the label exists on included namespaces, update rules to ignore the case
when the label is missing on the included namespaces.

Add old instance field to the namespace validator. Decode it from
request to compare with the new instance. Add more test cases since we
now have more combination of cases to test.

Update the namespace tree label update logs and function name in the HC
reconciler to make it clear that the HC reconciler only updates the tree
labels and won't update included-namespace label if the MWH works fine.

Tested by `make test` with new test cases. Also tested manually by
applying namespace manifests with different labels, viewed the logs and
verified the MWH and VWH work fine.
@yiqigao217
Copy link
Contributor Author

Please take another look. Meanwhile, I will make the manual test into e2e tests in the next PR.

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
/approve
/cc @rjbez17

Hey Ryan, today's Yiqi's last day working on this so I'm just going to approve it. If you have any concerns I can make the changes next week. Thanks!

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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 20, 2021
@k8s-ci-robot k8s-ci-robot merged commit be92981 into kubernetes-sigs:master May 20, 2021
@adrianludwin adrianludwin added this to the release-v0.9 milestone Oct 13, 2021
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. 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.

Consider using a mutating webhook on included namespaces
4 participants