Skip to content

Commit b6bffeb

Browse files
authored
Merge pull request #270 from andyzhangx/remove-lock
fix: remove unnecessary lock in NodePublish
2 parents 302af1b + 487c1c5 commit b6bffeb

File tree

2 files changed

+0
-39
lines changed

2 files changed

+0
-39
lines changed

pkg/smb/nodeserver.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
6565
return nil, status.Error(codes.InvalidArgument, "Staging target not provided")
6666
}
6767

68-
if acquired := d.volumeLocks.TryAcquire(volumeID); !acquired {
69-
return nil, status.Errorf(codes.Aborted, volumeOperationAlreadyExistsFmt, volumeID)
70-
}
71-
defer d.volumeLocks.Release(volumeID)
72-
7368
mountOptions := []string{"bind"}
7469
if req.GetReadonly() {
7570
mountOptions = append(mountOptions, "ro")
@@ -130,10 +125,6 @@ func (d *Driver) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublish
130125
if len(targetPath) == 0 {
131126
return nil, status.Error(codes.InvalidArgument, "Target path missing in request")
132127
}
133-
if acquired := d.volumeLocks.TryAcquire(volumeID); !acquired {
134-
return nil, status.Errorf(codes.Aborted, volumeOperationAlreadyExistsFmt, volumeID)
135-
}
136-
defer d.volumeLocks.Release(volumeID)
137128

138129
klog.V(2).Infof("NodeUnpublishVolume: unmounting volume %s on %s", volumeID, targetPath)
139130
err := CleanupMountPoint(d.mounter, targetPath, false)

pkg/smb/nodeserver_test.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -304,23 +304,6 @@ func TestNodePublishVolume(t *testing.T) {
304304
WindowsError: status.Errorf(codes.Internal, "Could not mount target %#v: mkdir %s: The system cannot find the path specified.", smbFile, smbFile),
305305
},
306306
},
307-
{
308-
desc: "[Error] Volume operation in progress",
309-
setup: func(d *Driver) {
310-
d.volumeLocks.TryAcquire("vol_1")
311-
},
312-
req: csi.NodePublishVolumeRequest{VolumeCapability: &csi.VolumeCapability{AccessMode: &volumeCap},
313-
VolumeId: "vol_1",
314-
TargetPath: targetTest,
315-
StagingTargetPath: sourceTest,
316-
Readonly: true},
317-
expectedErr: testutil.TestError{
318-
DefaultError: status.Error(codes.Aborted, fmt.Sprintf(volumeOperationAlreadyExistsFmt, "vol_1")),
319-
},
320-
cleanup: func(d *Driver) {
321-
d.volumeLocks.Release("vol_1")
322-
},
323-
},
324307
{
325308
desc: "[Error] Mount error mocked by Mount",
326309
req: csi.NodePublishVolumeRequest{VolumeCapability: &csi.VolumeCapability{AccessMode: &volumeCap},
@@ -422,19 +405,6 @@ func TestNodeUnpublishVolume(t *testing.T) {
422405
DefaultError: status.Error(codes.InvalidArgument, "Target path missing in request"),
423406
},
424407
},
425-
{
426-
desc: "[Error] Volume operation in progress",
427-
setup: func(d *Driver) {
428-
d.volumeLocks.TryAcquire("vol_1")
429-
},
430-
req: csi.NodeUnpublishVolumeRequest{TargetPath: targetFile, VolumeId: "vol_1"},
431-
expectedErr: testutil.TestError{
432-
DefaultError: status.Error(codes.Aborted, fmt.Sprintf(volumeOperationAlreadyExistsFmt, "vol_1")),
433-
},
434-
cleanup: func(d *Driver) {
435-
d.volumeLocks.Release("vol_1")
436-
},
437-
},
438408
{
439409
desc: "[Error] Unmount error mocked by IsLikelyNotMountPoint",
440410
req: csi.NodeUnpublishVolumeRequest{TargetPath: errorTarget, VolumeId: "vol_1"},

0 commit comments

Comments
 (0)