Bug 1842964

Summary: volumesnapshot instance can not be deleted when the volumesnapshotcontent instance's deletionpolicy changed from Delete to Retain
Product: OpenShift Container Platform Reporter: Qin Ping <piqin>
Component: StorageAssignee: Christian Huffman <chuffman>
Storage sub component: Kubernetes External Components QA Contact: Wei Duan <wduan>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: medium CC: aos-bugs, jsafrane
Version: 4.5   
Target Milestone: ---   
Target Release: 4.6.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Finalizers are added to VolumeSnapshot objects to prevent their deletion before any associated resources are removed. These finalizers were not updated if the associated VolumeSnapshotContent's deletion policy was updated. Consequence: The VolumeSnapshot object could not be deleted, as the finalizers were never removed. Fix: The logic for finalizers was reworked. These are now correctly removed if the VolumeSnapshotContent's deletion policy is modified. Result: VolumeSnapshot instances can now be deleted successfully if the associated objects are removed.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-27 16:03:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Qin Ping 2020-06-02 13:04:43 UTC
Description of problem:
volumesnapshot instance can not be deleted when the volumesnapshotcontent instance's deletionpolicy changed from Delete 

Version-Release number of selected component (if applicable):
$ oc get clusterversion
NAME      VERSION                             AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.5.0-0.nightly-2020-05-30-025738   True        False         30h     Cluster version is 4.5.0-0.nightly-2020-05-30-025738

How reproducible:
Always

Steps to Reproduce:
1. Install aws ebs csi driver with operator
2. Create volumesnapshotclass with deletionPolicy=Delete
$ cat volumesnapshotclass.yaml 
apiVersion: snapshot.storage.k8s.io/v1beta1
kind: VolumeSnapshotClass  
metadata:
  name: csi-aws-ebs-snapclass
  annotations:
    snapshot.storage.kubernetes.io/is-default-class: "true"
driver: ebs.csi.aws.com
deletionPolicy: Delete
3. Create a volumesnapshot instance with this volumesnapshotclass
$ cat volumesnapshot.yaml 
apiVersion: snapshot.storage.k8s.io/v1beta1
kind: VolumeSnapshot
metadata:
  name: mysnapp-2
spec:
  volumeSnapshotClassName: csi-aws-ebs-snapclass
  source:
    persistentVolumeClaimName: pvc2
4. After the volumesnapshotcontent instance becomes ReadyToUse, update the volumesnapshotcontent instance's deletionpolicy from "Delete" to "Retain".
5. Delete the volumesnapshot instance

Actual results:
volumesnapshot instance can not be deleted, after the volumesnapshotcontent instance's deletionpolicy reset to "Delete", the volumesnapshot instance is deleted successfully.

Expected results:
the volumesnapshot instance can be deleted.

Master Log:

Node Log (of failed PODs):

PV Dump:

PVC Dump:

StorageClass Dump (if StorageClass used by PV/PVC):

Additional info:
When creating volumesnapshot instance with a volumesnapshotclass with "Retaion" deletion policy, the volumesnapshot instance can be deleted.

Comment 3 Christian Huffman 2020-06-29 22:16:04 UTC
I submitted a PR [1] to address this upstream. This PR removes the bound Finalizer if the snapshotContent is modified to Retain.

[1] https://github.com/kubernetes-csi/external-snapshotter/pull/327

Comment 5 Christian Huffman 2020-07-13 20:42:39 UTC
I was mistaken previously - it looks like this issue persists up until v2.1.0 upstream. In v2.1.1 and later, this issue is addressed. We'll be able to close this one out once we rebase the external-snapshotter.

Comment 7 Christian Huffman 2020-07-28 14:57:46 UTC
The PR to rebase [1] the CSI snapshot controller operator has been merged into master, which should resolve this issue. Setting to MODIFIED.

[1] https://github.com/openshift/cluster-csi-snapshot-controller-operator/pull/43

Comment 10 Wei Duan 2020-08-07 00:42:34 UTC
Verified pass 

$ oc get clusterversion
NAME      VERSION                             AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.6.0-0.nightly-2020-08-06-131904   True        False         36m     Cluster version is 4.6.0-0.nightly-2020-08-06-131904


1. Create volumesnapshot instance, volumesnapshotcontent is DELETIONPOLICY=Delete
$ oc get volumesnapshot
NAME            READYTOUSE   SOURCEPVC   SOURCESNAPSHOTCONTENT   RESTORESIZE   SNAPSHOTCLASS           SNAPSHOTCONTENT                                    CREATIONTIME   AGE
mysnapshot-01   true         mypvc01                             3Gi           csi-aws-ebs-snapclass   snapcontent-5a1c8435-ef3a-42e6-9d1a-2f1808ce90fe   85s            85s
$ oc get volumeSNAPSHOTCONTENT
NAME                                               READYTOUSE   RESTORESIZE   DELETIONPOLICY   DRIVER            VOLUMESNAPSHOTCLASS     VOLUMESNAPSHOT   AGE
snapcontent-5a1c8435-ef3a-42e6-9d1a-2f1808ce90fe   true         3221225472    Delete           ebs.csi.aws.com   csi-aws-ebs-snapclass   mysnapshot-01    105s

2. Update the volumesnapshotcontent instance's deletionpolicy from "Delete" to "Retain"
$ oc get volumeSNAPSHOTCONTENT
NAME                                               READYTOUSE   RESTORESIZE   DELETIONPOLICY   DRIVER            VOLUMESNAPSHOTCLASS     VOLUMESNAPSHOT   AGE
snapcontent-5a1c8435-ef3a-42e6-9d1a-2f1808ce90fe   true         3221225472    Retain           ebs.csi.aws.com   csi-aws-ebs-snapclass   mysnapshot-01    2m56s

3. Delete volumesnapshot instance successfully, and volumesnapshotcontent is "Retain"
$ oc delete volumesnapshot mysnapshot-01
volumesnapshot.snapshot.storage.k8s.io "mysnapshot-01" deleted
$ oc get volumesnapshot mysnapshot-01
Error from server (NotFound): volumesnapshots.snapshot.storage.k8s.io "mysnapshot-01" not found
$ oc get volumeSNAPSHOTCONTENT
NAME                                               READYTOUSE   RESTORESIZE   DELETIONPOLICY   DRIVER            VOLUMESNAPSHOTCLASS     VOLUMESNAPSHOT   AGE
snapcontent-5a1c8435-ef3a-42e6-9d1a-2f1808ce90fe   true         3221225472    Retain           ebs.csi.aws.com   csi-aws-ebs-snapclass   mysnapshot-01    3m29s

Comment 12 errata-xmlrpc 2020-10-27 16:03:47 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Container Platform 4.6 GA Images), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4196