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

Check for non-CSI PVs and mark not in use as appropriate #354

Closed
wants to merge 1 commit into from

Conversation

huffmanca
Copy link
Contributor

What type of PR is this?
/kind bug

What this PR does / why we need it:
Currently, if you specify a PVC and that PVC was created by an in-tree driver we never create the content and cannot delete the snapshot, as the source finalizer is never removed.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 12, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @huffmanca. 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: huffmanca
To complete the pull request process, please assign lpabon
You can assign the PR to them by writing /assign @lpabon in a comment when ready.

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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 12, 2020
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 12, 2020
@huffmanca huffmanca changed the title Check for non-CSI PVs and mark not in use as appropriate WIP: Check for non-CSI PVs and mark not in use as appropriate Aug 12, 2020
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 12, 2020
@huffmanca huffmanca changed the title WIP: Check for non-CSI PVs and mark not in use as appropriate Check for non-CSI PVs and mark not in use as appropriate Aug 13, 2020
@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 Aug 13, 2020
@huffmanca
Copy link
Contributor Author

This approach (checking to see if the backing volume is CSI before adding the finalizer to the PVC) has worked when I've manually tested it. The VolumeSnapshot can be deleted, as the PVC doesn't have the finalizer when the snapshot is scheduled for deletion.

@@ -819,8 +819,17 @@ func (ctrl *csiSnapshotCommonController) ensurePVCFinalizer(snapshot *crdv1.Volu
return newControllerUpdateError(pvc.Name, "cannot add finalizer on claim because it is being deleted")
}

// Check to see if the backing PV is created by a CSI driver. If not, then remove the Finalizer,
// as the snapshot can't be created from this PVC
pv, err := ctrl.getVolumeFromVolumeSnapshot(snapshot)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could fail for other reasons. This method does not really check if PV is backed by a CSI driver.

@xing-yang
Copy link
Collaborator

I have submitted this PR #360 for the finalizer deletion problem. Can you give a try?

For the problem that you reported, I think we should check early and fail early.

After the call to checkAndUpdateSnapshotClass in common-controller/snapshot_controller_base.go, we can add a small function with the following steps:

  • If snapshotClass is found, get snapshotClass.
  • find StorageClass from Snapshot’s source PVC.
  • Compare storageClass.Provisioner with snapshotClass.Driver.
  • If they are different, return error.

@huffmanca
Copy link
Contributor Author

@xing-yang ,

I tested your #360 PR, and it addresses this issue. I am able to successfully delete a VolumeSnapshot that is backed by a non-CSI PVC. The finalizer is also removed from the PVC.

I'll close this PR, and have commented on #360.

@huffmanca huffmanca closed this Aug 17, 2020
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. release-note-none Denotes a PR that doesn't merit a release note. 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.

3 participants