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

fix: add finalizer to prevent volume leakage #1179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

1978629634
Copy link
Contributor

@1978629634 1978629634 commented Mar 19, 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 bug

What this PR does / why we need it:

Add a annotation volume.kubernetes.io/provisioning-consistency to pvc. When the annotation is set to enable, use a finalizer to ensure that the lifecycle of the PVC is consistent with the associated volume, preventing volume leakage.

The finalizer is removed under two conditions:

1.When the annotation volume.kubernetes.io/provisioning-consistency is set to disable on the PVC, or

2.When the associated PV has been provisioned successfully.

Removing the finalizer allows the PVC to be deleted safely without causing the volume to leak.

Which issue(s) this PR fixes:

Fixes #486

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


When the annotation volume.kubernetes.io/provisioning-consistency is added to a PVC with the value enable, a provisioning protection finalizer will be added before creating the volume and removed after setting pvc.spec.volumeName.

If the PVC is being deleted and volume.kubernetes.io/provisioning-consistency is set to disable, the finalizer will be removed, abandoning the provisioning process. A CSI driver may be provisioning the volume and this volume may leak.

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 19, 2024
Copy link

linux-foundation-easycla bot commented Mar 19, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: 1978629634 / name: Chen Pu (7eafefd)

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 19, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @1978629634!

It looks like this is your first PR to kubernetes-csi/external-provisioner 🎉. 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-provisioner 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 Mar 19, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @1978629634. 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
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 1978629634
Once this PR has been reviewed and has the lgtm label, please assign xing-yang 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 k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 19, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 19, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 29, 2024
@1978629634 1978629634 force-pushed the fix-volume-leak branch 3 times, most recently from 6dd1e1c to 30e8feb Compare March 29, 2024 07:37
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 29, 2024
Copy link
Contributor

@jsafrane jsafrane left a comment

Choose a reason for hiding this comment

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

@1978629634 Thanks a lot for looking into this! I am afraid this is a complex problem and it will need more thoughts.

  1. It probably belongs to https://github.com/kubernetes-sigs/sig-storage-lib-external-provisioner/
  2. In ideal case, it should work as user friendly as possible. Today users can simply delete a PVC when it's stuck provisioning and create a new one with a different StorageClass. Kubernetes should do the right thing without leaks and magic annotations. The hard part is to find out how. Or if we expect users to change their behavior, we need really strong arguments.
    • Should there be a new PVC field instead of an annotation? Can we expect users to set it correctly? What prevents users from setting it to "disabled / I don't care about leaks"? It's cluster admin who will then need to deal with the leaks, not user. Do we as Kubernetes authors care?
    • Should the field be somewhere else, under admin control? Then users can still remove finalizers from their PVCs, creating leaks anyway.
    • Should we fix the provisioner in any other way, e.g. create a shadow object copying the PVC and continue calling Provision() until it gets a final response or cluster admin deletes this shadow object?

We need answers to these questions before we implement anything.
cc @msau42 @xing-yang

pkg/controller/controller.go Outdated Show resolved Hide resolved
@1978629634 1978629634 force-pushed the fix-volume-leak branch 2 times, most recently from 7822d9c to 851b715 Compare April 8, 2024 09:30
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 14, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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-sigs/prow repository.

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/bug Categorizes issue or PR as related to a bug. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

volume leak after CreateVolume started and before PV creation
3 participants