Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Enable removing bad subns anchors safely #799

Merged
merged 1 commit into from
Jun 19, 2020

Conversation

yiqigao217
Copy link
Contributor

@yiqigao217 yiqigao217 commented Jun 11, 2020

Allow removing bad subns anchor if the subnamespace already exists and
the parent doesn't match. The race condition could happen when two
parents both create the same subns the same time and the webhook is
bypassed because the forest is not updated after the first change. We
would always allow resolving a bad state.

Most importantly, make sure the subnamespace is not deleted with the
deletion of a bad anchor. Before this change, the subnamespace created
from a good anchor will also be deleted when deleting a bad anchor.

Tested by test-issue-797-leaf.sh and test-issue-797-non-leaf.sh, where
they disable the webhook first to generate the race condition in both a
leaf and non-leaf subnamespace and enable the webhook to test the
change. One unit test case is added to the anchor validator too.

Fixes #797

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 11, 2020
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 11, 2020
@yiqigao217
Copy link
Contributor Author

/hold until #788 is merged (both changed anchor validator and its unit test)
/assign @adrianludwin
/assign @rjbez17

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 11, 2020
@yiqigao217
Copy link
Contributor Author

Please hold review on this, I will let you know once it's ready.
/hold

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 11, 2020
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 11, 2020
@yiqigao217 yiqigao217 changed the title Allow removing bad subns anchor Enable removing bad subns anchors safely Jun 11, 2020
@yiqigao217
Copy link
Contributor Author

Hi @adrianludwin and @rjbez17, it's ready for review now.

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.

Two small nits but otherwise lgtm.

incubator/hnc/hack/test-issue-797-non-leaf.sh Outdated Show resolved Hide resolved
incubator/hnc/internal/validators/anchor_test.go Outdated Show resolved Hide resolved
Allow removing bad subns anchor if the subnamespace already exists and
the parent doesn't match. The race condition could happen when two
parents both create the same subns the same time and the webhook is
bypassed because the forest is not updated after the first change. We
would always allow resolving a bad state.

Most importantly, make sure the subnamespace is not deleted with the
deletion of a bad anchor. Before this change, the subnamespace created
from a good anchor will also be deleted when deleting a bad anchor.

Tested by test-issue-797-leaf.sh and test-issue-797-non-leaf.sh, where
they disable the webhook first to generate the race condition in both a
leaf and non-leaf subnamespace and enable the webhook to test the
change. One unit test case is added to the anchor validator too.
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
/assign @rjbez17
/hold

@k8s-ci-robot k8s-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 12, 2020
@yiqigao217
Copy link
Contributor Author

Hi @adrianludwin , I also changed the ensuring of the subnamespace is not deleted by seeing the created secret is still there instead of matching the creatingTimestamp.

@rjbez17
Copy link

rjbez17 commented Jun 19, 2020

/lgtm
/approve
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 19, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianludwin, rjbez17, 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:
  • OWNERS [adrianludwin,rjbez17]

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 merged commit ea4ed3e into kubernetes-retired:master Jun 19, 2020
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 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.

Deleting an anchor in the "conflict" state can also delete the namespace from another parent
4 participants