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

delete the content if creation failed and snapshot deleted #1064

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

huww98
Copy link

@huww98 huww98 commented Apr 13, 2024

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug

/kind cleanup

/kind design
/kind documentation
/kind failing-test

/kind feature

/kind flake

What this PR does / why we need it:

This is useful for Retain policy snapshot. When volume snapshot is created with invalid config, then deleted, all things should be cleaned up, instead of leaving a content to retry creation infinitely.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Some cleanups are included, please see commit message.

A new RBAC permission is added.

Does this PR introduce a user-facing change?:

No retry of creation is performed after the VolumeSnapshot is deleted.

Add bound finalizer to Retain policy snapshots to make sure the annotate logic
in checkandRemoveSnapshotFinalizersAndCheckandDeleteContent() effective.

The added finalizer does not change the current behaviour, because the source
finalizer is always added and only removed after the vs-deleted annotation is
added successfully. But we should not rely on this behaviour in case of future
changes.

The original annotate logic in syncContent() is not needed because all deleting
snapshot will go through above logic. And natually, if a content is never
bound, is will never get the vs-deleted annotation.

This also makes Retain and Delete policy snapshot more similar, which should
bring less surprises.
This is useful for Retain policy snapshot. When volume snapshot is created with
invalid config, then deleted, all things should be cleaned up, instead of
leaving a content to retry creation infinitely.
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 13, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: huww98
Once this PR has been reviewed and has the lgtm label, please assign saad-ali for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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
Copy link
Contributor

Welcome @huww98!

It looks like this is your first PR to kubernetes-csi/external-snapshotter 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-csi/external-snapshotter has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 13, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @huww98. Thanks for your PR.

I'm waiting for a kubernetes-csi 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 13, 2024
@huww98
Copy link
Author

huww98 commented Apr 13, 2024

/cc @xing-yang
as I see your NOTE in comment. And you also appear in git blame

},
expectSuccess: false,
test: testSyncContentError,
expectSuccess: true,
Copy link
Author

Choose a reason for hiding this comment

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

I think we should always do expectSuccess: true? Specify false means don't check for failure, not asserting error is returned. But that is a big project. Let's leave it to another PR.

// sidecar controller depending on the deletion policy
// on the content.
// Snapshot won't be deleted until content is deleted
// due to the finalizer.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the reason to remove this whole block?

Copy link
Author

Choose a reason for hiding this comment

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

// regardless of the deletion policy, set the VolumeSnapshotBeingDeleted on
// content object, this is to allow snapshotter sidecar controller to conduct
// a delete operation whenever the content has deletion timestamp set.
if content != nil {
klog.V(5).Infof("checkandRemoveSnapshotFinalizersAndCheckandDeleteContent[%s]: Set VolumeSnapshotBeingDeleted annotation on the content [%s]", utils.SnapshotKey(snapshot), content.Name)
updatedContent, err := ctrl.setAnnVolumeSnapshotBeingDeleted(content)

This code should already handle it.

In the commit message of second commit, I wrote:

The original annotate logic in syncContent() is not needed because all deleting snapshot will go through above logic. And natually, if a content is never bound, is will never get the vs-deleted annotation.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @xing-yang What do you think about the overall direction of this PR? Should we continue to work on this? These change is not required for this PR. If you agree, I can defer it to another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

None yet

3 participants