Skip to content

Commit 5480c1c

Browse files
committed
Add resources configuration to restore container
A new config is added to control the restore container. Default values are set for the new init container. It can be changed by user in the config. The config uses same logic as the project clone container config. Signed-off-by: Ales Raszka <araszka@redhat.com>
1 parent 728f107 commit 5480c1c

13 files changed

+1465
-6
lines changed

apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ type WorkspaceConfig struct {
144144
// ProjectCloneConfig defines configuration related to the project clone init container
145145
// that is used to clone git projects into the DevWorkspace.
146146
ProjectCloneConfig *ProjectCloneConfig `json:"projectClone,omitempty"`
147+
// RestoreConfig defines configuration related to the workspace restore init container
148+
// that is used to restore workspace data from a backup image.
149+
RestoreConfig *RestoreConfig `json:"restore,omitempty"`
147150
// ImagePullPolicy defines the imagePullPolicy used for containers in a DevWorkspace
148151
// For additional information, see Kubernetes documentation for imagePullPolicy. If
149152
// not specified, the default value of "Always" is used.
@@ -376,6 +379,16 @@ type ProjectCloneConfig struct {
376379
Env []corev1.EnvVar `json:"env,omitempty"`
377380
}
378381

382+
type RestoreConfig struct {
383+
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
384+
// Resources defines the resource (cpu, memory) limits and requests for the restore
385+
// container. To explicitly not specify a limit or request, define the resource
386+
// quantity as zero ('0')
387+
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
388+
// Env allows defining additional environment variables for the restore container.
389+
Env []corev1.EnvVar `json:"env,omitempty"`
390+
}
391+
379392
type ConfigmapReference struct {
380393
// Name is the name of the configmap
381394
Name string `json:"name"`

apis/controller/v1alpha1/zz_generated.deepcopy.go

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controllers/workspace/devworkspace_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
357357
if restore.IsWorkspaceRestoreRequested(&workspace.Spec.Template) {
358358
// Add init container to restore workspace from backup if requested
359359
restoreOptions := restore.Options{
360-
Env: env.GetEnvironmentVariablesForProjectRestore(workspace),
360+
Env: env.GetEnvironmentVariablesForProjectRestore(workspace),
361+
Resources: workspace.Config.Workspace.RestoreConfig.Resources,
361362
}
362363
if config.Workspace.ImagePullPolicy != "" {
363364
restoreOptions.PullPolicy = corev1.PullPolicy(config.Workspace.ImagePullPolicy)

deploy/bundle/manifests/controller.devfile.io_devworkspaceoperatorconfigs.yaml

Lines changed: 218 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)