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 helm.sh/resource-policy: keep to CRDs to prevent deletion #500

Merged

Conversation

Danil-Grigorev
Copy link
Member

What this PR does / why we need it:

When CAPI Operator chart used as a dependency, the removal of the chart hosting the dependency causes CRDs to be removed. This happens because CRDs are generated as a part of base and therefore are managed by helm 3. Helm docs define keep policy as:

skip deleting this resource when a helm operation (such as helm uninstall, helm upgrade or helm rollback) would result in its deletion

Setting this annotation should not prevent CRD upgrades, when resource is changed only.

Typically this removal happens after the main deployment is removed, and before any or all of the *Provider resources are removed. Provider resources has a finalizer, nothing can remove at this point, so the deletion hangs and later fails. Happens because CRD removal requires all resources it defines to be cleaned up before being removed itself.

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 #

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 24, 2024
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 24, 2024
Copy link

netlify bot commented Apr 24, 2024

Deploy Preview for kubernetes-sigs-cluster-api-operator ready!

Name Link
🔨 Latest commit 5a19c98
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-operator/deploys/6629053b4097850007351410
😎 Deploy Preview https://deploy-preview-500--kubernetes-sigs-cluster-api-operator.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Danil-Grigorev Danil-Grigorev force-pushed the retain-crds-on-delete branch from 39471e7 to a6c4edb Compare April 24, 2024 12:52
Copy link
Contributor

@Fedosin Fedosin left a comment

Choose a reason for hiding this comment

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

For chart we have a dedicated section: https://github.com/kubernetes-sigs/cluster-api-operator/tree/main/config/chart
Maybe it's better to put your patch there, since it affects the chart only?

Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
@Danil-Grigorev
Copy link
Member Author

I added it there @Fedosin, although in this case an additional annotation makes difference for helm only anyway. Helm does not care what is on resource, it needs this annotation in the chart resources, so it can’t do anything regardless of the placement

@Danil-Grigorev
Copy link
Member Author

I performed some testing of the helm upgrade, everything works with this change, so the docs are not wrong. Unless the resource is removed, this annotation changes nothing.

Copy link
Contributor

@alexander-demicev alexander-demicev left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexander-demicev

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 Apr 25, 2024
Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold

To avoid merging, in case @Fedosin has some more questions, otherwise unhold

@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 Apr 29, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 29, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 6f5e401c8eba3469de079022fc70627cb7eb575b

Copy link
Contributor

@Fedosin Fedosin left a comment

Choose a reason for hiding this comment

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

/lgtm
/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 Apr 29, 2024
@k8s-ci-robot k8s-ci-robot merged commit 505d465 into kubernetes-sigs:main Apr 29, 2024
14 checks passed
@Danil-Grigorev
Copy link
Member Author

/cherry-pick release-0.10

@k8s-infra-cherrypick-robot

@Danil-Grigorev: new pull request created: #503

In response to this:

/cherry-pick release-0.10

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. 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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants