Skip to content

Commit

Permalink
issue 6786:always delete VSC regardless of the deletion policy
Browse files Browse the repository at this point in the history
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
  • Loading branch information
Lyndon-Li committed Sep 15, 2023
1 parent 8a366c6 commit 53489b1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/6827-Lyndon-Li
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue #6786, always delete VSC regardless of the deletion policy
2 changes: 1 addition & 1 deletion pkg/exposer/csi_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (e *csiSnapshotExposer) createBackupVSC(ctx context.Context, ownerObject co
Source: snapshotv1api.VolumeSnapshotContentSource{
SnapshotHandle: snapshotVSC.Status.SnapshotHandle,
},
DeletionPolicy: snapshotVSC.Spec.DeletionPolicy,
DeletionPolicy: snapshotv1api.VolumeSnapshotContentDelete,
Driver: snapshotVSC.Spec.Driver,
VolumeSnapshotClassName: snapshotVSC.Spec.VolumeSnapshotClassName,
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/csi/volume_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func GetVolumeSnapshotContentForVolumeSnapshot(volSnap *snapshotv1api.VolumeSnap
func RetainVSC(ctx context.Context, snapshotClient snapshotter.SnapshotV1Interface,
vsc *snapshotv1api.VolumeSnapshotContent) (*snapshotv1api.VolumeSnapshotContent, error) {
if vsc.Spec.DeletionPolicy == snapshotv1api.VolumeSnapshotContentRetain {
return nil, nil
return vsc, nil
}
origBytes, err := json.Marshal(vsc)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions pkg/util/csi/volume_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,14 @@ func TestRetainVSC(t *testing.T) {
DeletionPolicy: snapshotv1api.VolumeSnapshotContentRetain,
},
},
updated: &snapshotv1api.VolumeSnapshotContent{
ObjectMeta: metav1.ObjectMeta{
Name: "fake-vsc",
},
Spec: snapshotv1api.VolumeSnapshotContentSpec{
DeletionPolicy: snapshotv1api.VolumeSnapshotContentRetain,
},
},
},
{
name: "path vsc fail",
Expand Down

0 comments on commit 53489b1

Please sign in to comment.