diff --git a/pkg/applicationmanager/controllers/applicationrestore.go b/pkg/applicationmanager/controllers/applicationrestore.go index c532f31a69..2b017e8ffb 100644 --- a/pkg/applicationmanager/controllers/applicationrestore.go +++ b/pkg/applicationmanager/controllers/applicationrestore.go @@ -688,6 +688,22 @@ func (a *ApplicationRestoreController) restoreVolumes(restore *storkapi.Applicat } } } + // Get restore volume batch sleep interval + volumeBatchSleepInterval, err := time.ParseDuration(k8sutils.DefaultRestoreVolumeBatchSleepInterval) + if err != nil { + logrus.Infof("error in parsing default restore volume sleep interval %s", k8sutils.DefaultRestoreVolumeBatchSleepInterval) + } + RestoreVolumeBatchSleepInterval, err := k8sutils.GetConfigValue(k8sutils.StorkControllerConfigMapName, metav1.NamespaceSystem, k8sutils.RestoreVolumeBatchSleepIntervalKey) + if err != nil { + logrus.Infof("error in reading %v cm, switching to default restore volume sleep interval", k8sutils.StorkControllerConfigMapName) + } else { + if len(RestoreVolumeBatchSleepInterval) != 0 { + volumeBatchSleepInterval, err = time.ParseDuration(RestoreVolumeBatchSleepInterval) + if err != nil { + logrus.Infof("error in conversion of volumeBatchSleepInterval: %v", err) + } + } + } for i := 0; i < len(backupVolInfos); i += batchCount { batchVolInfo := backupVolInfos[i:min(i+batchCount, len(backupVolInfos))] @@ -724,7 +740,7 @@ func (a *ApplicationRestoreController) restoreVolumes(restore *storkapi.Applicat _, err = a.updateRestoreCRInVolumeStage(namespacedName, storkapi.ApplicationRestoreStatusFailed, storkapi.ApplicationRestoreStageFinal, message, nil) return err } - time.Sleep(k8sutils.RestoreVolumeBatchSleepInterval) + time.Sleep(volumeBatchSleepInterval) restore, err = a.updateRestoreCRInVolumeStage( namespacedName, storkapi.ApplicationRestoreStatusInProgress, diff --git a/pkg/k8sutils/k8sutils.go b/pkg/k8sutils/k8sutils.go index f9baeb459e..a4d5dc90c4 100644 --- a/pkg/k8sutils/k8sutils.go +++ b/pkg/k8sutils/k8sutils.go @@ -53,13 +53,15 @@ const ( RestoreVolumeBatchCountKey = "restore-volume-backup-count" // DefaultRestoreVolumeBatchCount - default value for restore volume batch count DefaultRestoreVolumeBatchCount = 25 - // RestoreVolumeBatchSleepInterval - restore volume batch sleep interval - RestoreVolumeBatchSleepInterval = 20 * time.Second // ResourceCountLimitKeyName defines the number of resources to be read via one List API call. // It is assigned to Limit field of ListOption structure ResourceCountLimitKeyName = "resource-count-limit" // DefaultResourceCountLimit defines the default value for resource count for list api DefaultResourceCountLimit = int64(500) + // DefaultRestoreVolumeBatchSleepInterval - restore volume batch sleep interval + DefaultRestoreVolumeBatchSleepInterval = "20s" + // RestoreVolumeBatchSleepIntervalKey - restore volume batch sleep interval key + RestoreVolumeBatchSleepIntervalKey = "restore-volume-sleep-interval" ) // JSONPatchOp is a single json mutation done by a k8s mutating webhook