Skip to content

Commit 29f2f95

Browse files
committed
Volume existance handled
1 parent 2b2e973 commit 29f2f95

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/driver/controller.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ func (d *controllerService) CreateVolume(ctx context.Context, req *csi.CreateVol
122122
VolumeType: volumeType,
123123
}
124124

125+
// check if disk exists
126+
// disk exists only if previous createVolume request fails due to any network/tcp error
127+
diskDetails, _ := d.cloud.GetDiskByName(volName)
128+
if diskDetails != nil {
129+
// wait for volume to be available as the volume already exists
130+
err := d.cloud.WaitForVolumeState(diskDetails.VolumeID, cloud.VolumeAvailableState)
131+
if err != nil {
132+
return nil, status.Errorf(codes.Internal, "Disk already exists and not in expected state")
133+
}
134+
return newCreateVolumeResponse(diskDetails), nil
135+
}
136+
125137
disk, err := d.cloud.CreateDisk(volName, opts)
126138
if err != nil {
127139
return nil, status.Errorf(codes.Internal, "Could not create volume %q: %v", volName, err)

0 commit comments

Comments
 (0)