Skip to content

Commit 5680f76

Browse files
authored
Add check for volume state in REST clone create path
This adds an extra check for volume state during for clone create operations in REST.
1 parent 724169b commit 5680f76

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

storage_drivers/ontap/ontap_common.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,18 +2692,10 @@ func cloneFlexvol(
26922692
return err
26932693
}
26942694

2695-
// NVMe clone is not ready by the time we return from VolumeCloneCreate.
2696-
// This check here makes sure that we don't fail the clone operation during the time clone is not ready
2697-
// Currently this change is done only for NVMe volumes but it should work with other volumes too if needed
2698-
if config.SANType == sa.NVMe {
2699-
2700-
desiredNVMeVolStates := []string{"online"}
2701-
abortNVMeVolStates := []string{"error"}
2702-
volState, err := client.VolumeWaitForStates(ctx, name, desiredNVMeVolStates, abortNVMeVolStates,
2703-
maxFlexvolCloneWait)
2704-
if err != nil {
2705-
return fmt.Errorf("unable to create flexClone for NVMe volume %v, volState:%v", name, volState)
2706-
}
2695+
desiredStates, abortStates := []string{"online"}, []string{"error"}
2696+
volState, err := client.VolumeWaitForStates(ctx, name, desiredStates, abortStates, maxFlexvolCloneWait)
2697+
if err != nil {
2698+
return fmt.Errorf("unable to create flexClone for volume %v, volState:%v", name, volState)
27072699
}
27082700

27092701
if err = client.VolumeSetComment(ctx, name, name, labels); err != nil {

storage_drivers/ontap/ontap_nas_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,8 @@ func TestOntapNasStorageDriverVolumeClone(t *testing.T) {
675675
mockAPI.EXPECT().VolumeExists(ctx, "").Return(false, nil)
676676
mockAPI.EXPECT().VolumeCloneCreate(ctx, volConfig.InternalName, volConfig.CloneSourceVolumeInternal,
677677
volConfig.CloneSourceSnapshotInternal, false).Return(nil)
678+
mockAPI.EXPECT().VolumeWaitForStates(ctx, volConfig.InternalName, gomock.Any(), gomock.Any(),
679+
maxFlexvolCloneWait).Return("online", nil)
678680
mockAPI.EXPECT().VolumeSetComment(ctx, volConfig.InternalName, volConfig.InternalName, "flexvol").
679681
Return(nil)
680682
mockAPI.EXPECT().VolumeMount(ctx, volConfig.InternalName, "/"+volConfig.InternalName).Return(nil)
@@ -946,6 +948,8 @@ func TestOntapNasStorageDriverVolumeClone_SMBShareCreateFail(t *testing.T) {
946948
mockAPI.EXPECT().VolumeExists(ctx, "").Return(false, nil)
947949
mockAPI.EXPECT().VolumeCloneCreate(ctx, volConfig.InternalName, volConfig.CloneSourceVolumeInternal,
948950
volConfig.CloneSourceSnapshotInternal, false).Return(nil)
951+
mockAPI.EXPECT().VolumeWaitForStates(ctx, volConfig.InternalName, gomock.Any(), gomock.Any(),
952+
maxFlexvolCloneWait).Return("online", nil)
949953
mockAPI.EXPECT().VolumeSetComment(ctx, volConfig.InternalName, volConfig.InternalName, "flexvol").Return(nil)
950954
mockAPI.EXPECT().VolumeMount(ctx, volConfig.InternalName, "/"+volConfig.InternalName).Return(nil)
951955
mockAPI.EXPECT().SMBShareExists(ctx, volConfig.InternalName).Return(false, nil)

0 commit comments

Comments
 (0)