From bd947bbe31ecc1e17fe4314462ae2e82b11925fb Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Fri, 9 Jul 2021 15:44:51 +0530 Subject: [PATCH] util: remove deleteLock check while acquiring snapshot createLock snapshot controller make sure the pvc which is the source for the snapshot request wont get deleted while snapshot is getting created, so we dont need to check for any ongoing delete operation here on the volume. Subjected code path in snapshot controller: ``` pvc, err := ctrl.getClaimFromVolumeSnapshot(snapshot) . .. pvcClone.ObjectMeta.Finalizers = append(pvcClone.ObjectMeta.Finalizers, utils.PVCFinalizer) _, err = ctrl.client.CoreV1().PersistentVolumeClaims(pvcClone.Namespace).Update(..) ``` Signed-off-by: Humble Chirammal --- internal/util/idlocker.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/internal/util/idlocker.go b/internal/util/idlocker.go index 7c3d1d84e..e4343a9b8 100644 --- a/internal/util/idlocker.go +++ b/internal/util/idlocker.go @@ -108,13 +108,10 @@ func (ol *OperationLock) tryAcquire(op operation, volumeID string) error { defer ol.mux.Unlock() switch op { case createOp: - // During snapshot create operation there should not be any delete - // operation going on for the volume. - - // check any delete operation is going on for given volume ID - if _, ok := ol.locks[deleteOp][volumeID]; ok { - return fmt.Errorf("a Delete operation with given id %s already exists", volumeID) - } + // snapshot controller make sure the pvc which is the source for the + // snapshot request won't get deleted while snapshot is getting created, + // so we dont need to check for any ongoing delete operation here on the + // volume. // increment the counter for snapshot create operation val := ol.locks[createOp][volumeID] ol.locks[createOp][volumeID] = val + 1