Add VolumeSnapshotBeingDeleted annotation to content
This commit is contained in:
@@ -249,6 +249,7 @@ func (ctrl *csiSnapshotCommonController) checkandRemoveSnapshotFinalizersAndChec
|
|||||||
}
|
}
|
||||||
|
|
||||||
klog.V(5).Infof("checkandRemoveSnapshotFinalizersAndCheckandDeleteContent[%s]: set DeletionTimeStamp on content.", utils.SnapshotKey(snapshot))
|
klog.V(5).Infof("checkandRemoveSnapshotFinalizersAndCheckandDeleteContent[%s]: set DeletionTimeStamp on content.", utils.SnapshotKey(snapshot))
|
||||||
|
|
||||||
// If content exists, set DeletionTimeStamp on the content;
|
// If content exists, set DeletionTimeStamp on the content;
|
||||||
// content won't be deleted immediately due to the finalizer
|
// content won't be deleted immediately due to the finalizer
|
||||||
if content != nil && deleteContent && !inUse {
|
if content != nil && deleteContent && !inUse {
|
||||||
@@ -261,6 +262,9 @@ func (ctrl *csiSnapshotCommonController) checkandRemoveSnapshotFinalizersAndChec
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !inUse {
|
if !inUse {
|
||||||
|
klog.V(5).Infof("checkandRemoveSnapshotFinalizersAndCheckandDeleteContent: Set VolumeSnapshotBeingDeleted annotation on the content [%s]", content.Name)
|
||||||
|
ctrl.setAnnVolumeSnapshotBeingDeleted(content)
|
||||||
|
|
||||||
klog.V(5).Infof("checkandRemoveSnapshotFinalizersAndCheckandDeleteContent: Remove Finalizer for VolumeSnapshot[%s]", utils.SnapshotKey(snapshot))
|
klog.V(5).Infof("checkandRemoveSnapshotFinalizersAndCheckandDeleteContent: Remove Finalizer for VolumeSnapshot[%s]", utils.SnapshotKey(snapshot))
|
||||||
doesContentExist := false
|
doesContentExist := false
|
||||||
if content != nil {
|
if content != nil {
|
||||||
|
@@ -21,6 +21,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
crdv1 "github.com/kubernetes-csi/external-snapshotter/v2/pkg/apis/volumesnapshot/v1beta1"
|
||||||
"github.com/kubernetes-csi/external-snapshotter/v2/pkg/utils"
|
"github.com/kubernetes-csi/external-snapshotter/v2/pkg/utils"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
storagev1beta1 "k8s.io/api/storage/v1beta1"
|
||||||
@@ -336,6 +337,20 @@ func TestSync(t *testing.T) {
|
|||||||
expectSuccess: false,
|
expectSuccess: false,
|
||||||
test: testSyncContentError,
|
test: testSyncContentError,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "5-5 - snapshot deletion candidate marked for deletion by syncSnapshot",
|
||||||
|
initialSnapshots: newSnapshotArray("snap5-5", "snapuid5-5", "claim5-5", "", validSecretClass, "content5-5", &False, nil, nil, nil, false, true, &timeNowMetav1),
|
||||||
|
expectedSnapshots: withSnapshotFinalizers(newSnapshotArray("snap5-5", "snapuid5-5", "claim5-5", "", validSecretClass, "content5-5", &False, nil, nil, nil, false, false, &timeNowMetav1),
|
||||||
|
utils.VolumeSnapshotBoundFinalizer,
|
||||||
|
),
|
||||||
|
initialContents: newContentArray("content5-5", "snapuid5-5", "snap5-5", "sid5-5", validSecretClass, "", "", crdv1.VolumeSnapshotContentRetain, nil, nil, true),
|
||||||
|
expectedContents: withContentAnnotations(newContentArray("content5-5", "snapuid5-5", "snap5-5", "sid5-5", validSecretClass, "", "", crdv1.VolumeSnapshotContentRetain, nil, nil, true), map[string]string{utils.AnnVolumeSnapshotBeingDeleted: "yes"}),
|
||||||
|
initialClaims: newClaimArray("claim5-5", "pvc-uid5-5", "1Gi", "volume5-5", v1.ClaimBound, &classEmpty),
|
||||||
|
initialVolumes: newVolumeArray("volume5-5", "pv-uid5-5", "pv-handle5-5", "1Gi", "pvc-uid5-5", "claim5-5", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty),
|
||||||
|
initialSecrets: []*v1.Secret{secret()},
|
||||||
|
expectSuccess: true,
|
||||||
|
test: testSyncSnapshot,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
runSyncTests(t, tests, snapshotClasses)
|
runSyncTests(t, tests, snapshotClasses)
|
||||||
|
Reference in New Issue
Block a user