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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 clusterctl: validate no objects exist from CRDs before deleting them #9808

Merged

Conversation

chrischdi
Copy link
Member

What this PR does / why we need it:

Adds a safeguard when clusterctl delete --include-crd is executed to not do anything if there are still Custom Resources for a CRD.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #9732

/area clusterctl

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. area/clusterctl Issues or PRs related to clusterctl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 5, 2023
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 5, 2023
@chrischdi chrischdi force-pushed the pr-clusterctl-protect-crs branch 2 times, most recently from 443266f to 3b05fbb Compare December 5, 2023 14:24
@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 Dec 5, 2023
@chrischdi chrischdi force-pushed the pr-clusterctl-protect-crs branch 2 times, most recently from 4e3e12d to 3455df0 Compare December 5, 2023 14:45
@chrischdi chrischdi changed the title [WIP]馃悰 clusterctl: validate no objects exist from CRDs before deleting them 馃悰 clusterctl: validate no objects exist from CRDs before deleting them Dec 5, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 5, 2023
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

Just a few nits

cmd/clusterctl/client/cluster/components.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/cluster/components.go Outdated Show resolved Hide resolved
@chrischdi
Copy link
Member Author

/retest

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Dec 6, 2023

@chrischdi: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-apidiff-main b8f1cc0 link false /test pull-cluster-api-apidiff-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@sbueringer
Copy link
Member

Thx!

/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 Dec 6, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: a733c0403a85c6734eacbb95652ec2efef2fd75a

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 Dec 6, 2023
@sbueringer
Copy link
Member

sbueringer commented Dec 6, 2023

If possible I would like to cherry-pick this into release-1.6 and release-1.5. I think it's currently not intended that clusterctl delete --include-crd triggers deletion of all CRs in a mgmt cluster. It can have catastrophic consequences and also our deletion reconciliations are not designed for all objects being deleted at the same time.

@CecileRobertMichon @enxebre @vincepri @fabriziopandini Fine for you if we cherry-pick?

@k8s-ci-robot k8s-ci-robot merged commit f330c6e into kubernetes-sigs:main Dec 6, 2023
19 of 20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.7 milestone Dec 6, 2023
@sbueringer
Copy link
Member

/cherry-pick release-1.6

@sbueringer
Copy link
Member

/cherry-pick release-1.5

@k8s-infra-cherrypick-robot

@sbueringer: #9808 failed to apply on top of branch "release-1.5":

Applying: clusterctl: validate no objects exist from CRDs before deleting them
Using index info to reconstruct a base tree...
M	cmd/clusterctl/client/cluster/components.go
M	cmd/clusterctl/client/cluster/components_test.go
M	cmd/clusterctl/client/delete.go
M	cmd/clusterctl/client/delete_test.go
Falling back to patching base and 3-way merge...
Auto-merging cmd/clusterctl/client/delete_test.go
Auto-merging cmd/clusterctl/client/delete.go
Auto-merging cmd/clusterctl/client/cluster/components_test.go
Auto-merging cmd/clusterctl/client/cluster/components.go
CONFLICT (content): Merge conflict in cmd/clusterctl/client/cluster/components.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 clusterctl: validate no objects exist from CRDs before deleting them
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.5

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-infra-cherrypick-robot

@sbueringer: new pull request created: #9834

In response to this:

/cherry-pick release-1.6

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.

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/clusterctl Issues or PRs related to clusterctl 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.

Ensure clusterctl delete --include-crds blocks if CR still exist
4 participants