Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@duanwei33
Copy link

What type of PR is this?
/kind feature

What this PR does / why we need it:
Add a new E2E test to verify that deleting a VolumeSnapshot does not delete the source PVC and PV.
The test:

  • Creates a snapshot of a persistent volume
  • Deletes the snapshot
  • Verifies that the source PVC and PV still exist
  • Verifies that the original data is intact
  • Verifies that the volume is still writable

This test covers both delete and retain snapshot deletion policies for dynamic and pre-provisioned snapshots."

Which issue(s) this PR is related to:
It could detect issues like https://issues.redhat.com/browse/OCPBUGS-62096

Does this PR introduce a user-facing change?
No

Execution

  $ _output/bin/e2e.test \
    -storage.testdriver=test/e2e/testing-manifests/storage-csi/hostpath/hostpath-testdriver.yaml \
    -ginkgo.focus="External Storage.*should verify that deleting snapshot does not delete the source volume \(persistent\)" \
    -ginkgo.v \
    -kubeconfig=${KUBECONFIG}

Ran 4 of 7552 Specs in 279.269 seconds
SUCCESS! -- 4 Passed | 0 Failed | 0 Pending | 7548 Skipped

Resource will be cleaned up after test:

$ kubectl get ns | grep snapshotting | wc -l
       0

  Add a new E2E test to verify that deleting a VolumeSnapshot does not
  delete the source PVC and PV. The test:
  - Creates a snapshot of a persistent volume
  - Deletes the snapshot
  - Verifies that the source PVC and PV still exist
  - Verifies that the original data is intact
  - Verifies that the volume is still writable

  This test covers both delete and retain snapshot deletion policies for
  dynamic and pre-provisioned snapshots.
@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. 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: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 13, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @duanwei33!

It looks like this is your first PR to kubernetes/kubernetes 🎉. 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/kubernetes 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
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot
Copy link
Contributor

Hi @duanwei33. Thanks for your PR.

I'm waiting for a github.com 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 13, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: duanwei33
Once this PR has been reviewed and has the lgtm label, please assign thockin for approval. For more information see the 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 area/test sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 13, 2025
Comment on lines +489 to +498
// Verify that the original PVC and PV still exist
ginkgo.By("verifying the source PVC still exists after snapshot deletion")
pvc, err = cs.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(ctx, pvc.Name, metav1.GetOptions{})
framework.ExpectNoError(err, "source PVC should still exist after snapshot deletion")
gomega.Expect(pvc.Status.Phase).To(gomega.Equal(v1.ClaimBound), "source PVC should still be in Bound state")

ginkgo.By("verifying the source PV still exists after snapshot deletion")
pv, err = cs.CoreV1().PersistentVolumes().Get(ctx, originalPVName, metav1.GetOptions{})
framework.ExpectNoError(err, "source PV should still exist after snapshot deletion")
gomega.Expect(pv.Name).To(gomega.Equal(originalPVName), "source PV name should match the original")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Verify that the original PVC and PV still exist
ginkgo.By("verifying the source PVC still exists after snapshot deletion")
pvc, err = cs.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(ctx, pvc.Name, metav1.GetOptions{})
framework.ExpectNoError(err, "source PVC should still exist after snapshot deletion")
gomega.Expect(pvc.Status.Phase).To(gomega.Equal(v1.ClaimBound), "source PVC should still be in Bound state")
ginkgo.By("verifying the source PV still exists after snapshot deletion")
pv, err = cs.CoreV1().PersistentVolumes().Get(ctx, originalPVName, metav1.GetOptions{})
framework.ExpectNoError(err, "source PV should still exist after snapshot deletion")
gomega.Expect(pv.Name).To(gomega.Equal(originalPVName), "source PV name should match the original")

From my understanding, the origin bug clean up the under layer origin volume by mistake. It seems there's no chance the snapshot controller/snappshotter will delete pvc/pv, so maybe we could omit these even though it is no harm.

ginkgo.By("verifying original data still exists in the volume")
readCmd := e2evolume.GenerateReadFileCmd(datapath)
_, err = e2eoutput.LookForStringInPodExec(verifyPod.Namespace, verifyPod.Name, readCmd, originalMntTestData, time.Minute)
framework.ExpectNoError(err, "original data should still be present in the volume")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
framework.ExpectNoError(err, "original data should still be present in the volume")
framework.ExpectNoError(err, "original data is not present in the volume")

Maybe better.

ginkgo.By("[init] deleting the pod")
StopPod(ctx, cs, pod)

// Wait for volume to be fully detached from the node
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment better to move before line:445, it seems a bit mislead here.

@Phaow
Copy link
Contributor

Phaow commented Nov 13, 2025

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed 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 Nov 13, 2025
@Phaow
Copy link
Contributor

Phaow commented Nov 13, 2025

nit: keep consistent with the example release-note in description could help the bot add the correct release-note label

Does this PR introduce a user-facing change?

NONE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. 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.

3 participants