Skip to content

Commit

Permalink
pb-3791: Add a config-map for batch volume restore sleep interval
Browse files Browse the repository at this point in the history
- In case portworx driver takes longer time for restore then the sleep interval
  may need to be altered for debug purpose for further analysis. Hence
  added a configmap restore-volume-sleep-interval.

- Currently it is set to default 20 seconds

Signed-off-by: Lalatendu Das <[email protected]>
  • Loading branch information
lalat-das committed Apr 21, 2023
1 parent dcb676b commit 3bbf62f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 17 additions & 1 deletion pkg/applicationmanager/controllers/applicationrestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions pkg/k8sutils/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3bbf62f

Please sign in to comment.