Skip to content

Commit b8f244e

Browse files
committed
prevent deletion of single snapshot that is part of a snapshotgroup
1 parent ddd6c68 commit b8f244e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/hostpath/controllerserver.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,11 @@ func (hp *hostPath) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotR
589589
hp.mutex.Lock()
590590
defer hp.mutex.Unlock()
591591

592+
// If the snapshot has a GroupSnapshotID, deletion is not allowed and should return InvalidArgument.
593+
if snapshot, err := hp.state.GetSnapshotByID(snapshotID); err != nil && snapshot.GroupSnapshotID != "" {
594+
return nil, status.Errorf(codes.InvalidArgument, "Snapshot with ID %s is part of groupsnapshot %s", snapshotID, snapshot.GroupSnapshotID)
595+
}
596+
592597
glog.V(4).Infof("deleting snapshot %s", snapshotID)
593598
path := hp.getSnapshotPath(snapshotID)
594599
os.RemoveAll(path)

0 commit comments

Comments
 (0)