Skip to content

Commit 970f72d

Browse files
authored
Removing polling when triggering clone split in REST
1 parent 000d24b commit 970f72d

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

storage_drivers/ontap/api/ontap_rest.go

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,16 +1128,30 @@ func (c *RestClient) startCloneSplitByNameAndStyle(ctx context.Context, volumeNa
11281128

11291129
params.SetInfo(volumeInfo)
11301130

1131-
_, volumeModifyAccepted, err := c.api.Storage.VolumeModify(params, c.authInfo)
1131+
volumeModifyOk, volumeModifyAccepted, err := c.api.Storage.VolumeModify(params, c.authInfo)
11321132
if err != nil {
11331133
return err
11341134
}
1135-
if volumeModifyAccepted == nil {
1135+
1136+
if volumeModifyOk == nil && volumeModifyAccepted == nil {
11361137
return fmt.Errorf("unexpected response from volume modify")
11371138
}
11381139

1139-
jobLink := getGenericJobLinkFromVolumeJobLink(volumeModifyAccepted.Payload)
1140-
return c.PollJobStatus(ctx, jobLink)
1140+
// If there is explicit error, return the error
1141+
if volumeModifyOk != nil && !volumeModifyOk.IsSuccess() {
1142+
return fmt.Errorf("failed to start clone split; %v", volumeModifyOk.Error())
1143+
}
1144+
1145+
if volumeModifyAccepted != nil && !volumeModifyAccepted.IsSuccess() {
1146+
return fmt.Errorf("failed to start clone split; %v", volumeModifyAccepted.Error())
1147+
}
1148+
1149+
// At this point, it is clear that no error occurred while trying to start the split.
1150+
// Since clone split usually takes time, we do not wait for its completion.
1151+
// Hence, do not get the jobLink and poll for its status. Assume, it is successful.
1152+
Logc(ctx).WithField("volume", volumeName).Debug(
1153+
"Clone split initiated successfully. This is an asynchronous operation, and its completion is not monitored.")
1154+
return nil
11411155
}
11421156

11431157
// restoreSnapshotByNameAndStyle restores a volume to a snapshot as a non-blocking operation
@@ -6941,16 +6955,30 @@ func (c *RestClient) StorageUnitCloneSplitStart(
69416955

69426956
params.SetInfo(suInfo)
69436957

6944-
_, suModifyAccepted, err := c.api.San.StorageUnitModify(params, c.authInfo)
6958+
suModifyOk, suModifyAccepted, err := c.api.San.StorageUnitModify(params, c.authInfo)
69456959
if err != nil {
69466960
return err
69476961
}
6948-
if suModifyAccepted == nil {
6949-
return fmt.Errorf("unexpected response from volume modify")
6962+
6963+
if suModifyOk == nil && suModifyAccepted == nil {
6964+
return fmt.Errorf("unexpected response from storage unit modify")
69506965
}
69516966

6952-
jobLink := getGenericJobLinkFromStorageUnitJobLink(suModifyAccepted.Payload)
6953-
return c.PollJobStatus(ctx, jobLink)
6967+
// If there is explicit error, return the error
6968+
if suModifyOk != nil && !suModifyOk.IsSuccess() {
6969+
return fmt.Errorf("failed to start clone split; %v", suModifyOk.Error())
6970+
}
6971+
6972+
if suModifyAccepted != nil && !suModifyAccepted.IsSuccess() {
6973+
return fmt.Errorf("failed to start clone split; %v", suModifyAccepted.Error())
6974+
}
6975+
6976+
// At this point, it is clear that no error occurred while trying to start the split.
6977+
// Since clone split usually takes time, we do not wait for its completion.
6978+
// Hence, do not get the jobLink and poll for its status. Assume, it is successful.
6979+
Logc(ctx).WithField("storageUnitUUID", suUUID).Debug(
6980+
"Clone split initiated successfully. This is an asynchronous operation, and its completion is not monitored.")
6981+
return nil
69546982
}
69556983

69566984
func (c *RestClient) StorageUnitListAllBackedBySnapshot(ctx context.Context, suName, snapshotName string) ([]string,

storage_drivers/ontap/ontap_common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4001,6 +4001,7 @@ func cloneFlexvol(
40014001
"source": source,
40024002
"snapshot": snapshot,
40034003
"split": split,
4004+
"labels": labels,
40044005
}
40054006
Logd(ctx, config.StorageDriverName, config.DebugTraceFlags["method"]).WithFields(fields).Trace(">>>> cloneFlexvol")
40064007
defer Logd(ctx, config.StorageDriverName,

0 commit comments

Comments
 (0)