-
Notifications
You must be signed in to change notification settings - Fork 67
Restore workspace from backup #1572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9a876c1
214b762
728f107
5480c1c
9db9b7c
dcbc7b3
1c706fe
83e8ac8
8fcc091
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ import ( | |
| "github.com/devfile/devworkspace-operator/pkg/library/home" | ||
| kubesync "github.com/devfile/devworkspace-operator/pkg/library/kubernetes" | ||
| "github.com/devfile/devworkspace-operator/pkg/library/projects" | ||
| "github.com/devfile/devworkspace-operator/pkg/library/restore" | ||
| "github.com/devfile/devworkspace-operator/pkg/library/status" | ||
| "github.com/devfile/devworkspace-operator/pkg/provision/automount" | ||
| "github.com/devfile/devworkspace-operator/pkg/provision/metadata" | ||
|
|
@@ -353,21 +354,51 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request | |
| if err := projects.ValidateAllProjects(&workspace.Spec.Template); err != nil { | ||
| return r.failWorkspace(workspace, fmt.Sprintf("Invalid devfile: %s", err), metrics.ReasonBadRequest, reqLogger, &reconcileStatus), nil | ||
| } | ||
| // Add init container to clone projects | ||
| projectCloneOptions := projects.Options{ | ||
| Image: workspace.Config.Workspace.ProjectCloneConfig.Image, | ||
| Env: env.GetEnvironmentVariablesForProjectClone(workspace), | ||
| Resources: workspace.Config.Workspace.ProjectCloneConfig.Resources, | ||
| } | ||
| if workspace.Config.Workspace.ProjectCloneConfig.ImagePullPolicy != "" { | ||
| projectCloneOptions.PullPolicy = config.Workspace.ProjectCloneConfig.ImagePullPolicy | ||
| if restore.IsWorkspaceRestoreRequested(&workspace.Spec.Template) { | ||
| // Add init container to restore workspace from backup if requested | ||
| restoreOptions := restore.Options{ | ||
| Env: env.GetEnvironmentVariablesForProjectRestore(workspace), | ||
| Resources: workspace.Config.Workspace.RestoreConfig.Resources, | ||
| } | ||
| if config.Workspace.ImagePullPolicy != "" { | ||
| restoreOptions.PullPolicy = corev1.PullPolicy(config.Workspace.ImagePullPolicy) | ||
| } else { | ||
| restoreOptions.PullPolicy = corev1.PullIfNotPresent | ||
| } | ||
| if workspaceRestore, registryAuthSecret, err := restore.GetWorkspaceRestoreInitContainer(ctx, workspace, r.Client, restoreOptions, r.Scheme, reqLogger); err != nil { | ||
| return r.failWorkspace(workspace, fmt.Sprintf("Failed to set up workspace-restore init container: %s", err), metrics.ReasonInfrastructureFailure, reqLogger, &reconcileStatus), nil | ||
| } else if workspaceRestore != nil { | ||
| devfilePodAdditions.InitContainers = append([]corev1.Container{*workspaceRestore}, devfilePodAdditions.InitContainers...) | ||
| if registryAuthSecret != nil { | ||
| // Add the registry auth secret volume | ||
| devfilePodAdditions.Volumes = append(devfilePodAdditions.Volumes, corev1.Volume{ | ||
| Name: "registry-auth-secret", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we define |
||
| VolumeSource: corev1.VolumeSource{ | ||
| Secret: &corev1.SecretVolumeSource{ | ||
| SecretName: registryAuthSecret.Name, // You may want to make this configurable | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| } | ||
| } else { | ||
| projectCloneOptions.PullPolicy = corev1.PullPolicy(config.Workspace.ImagePullPolicy) | ||
| } | ||
| if projectClone, err := projects.GetProjectCloneInitContainer(&workspace.Spec.Template, projectCloneOptions, workspace.Config.Routing.ProxyConfig); err != nil { | ||
| return r.failWorkspace(workspace, fmt.Sprintf("Failed to set up project-clone init container: %s", err), metrics.ReasonInfrastructureFailure, reqLogger, &reconcileStatus), nil | ||
| } else if projectClone != nil { | ||
| devfilePodAdditions.InitContainers = append([]corev1.Container{*projectClone}, devfilePodAdditions.InitContainers...) | ||
| // Add init container to clone projects only if restore container wasn't created | ||
| projectCloneOptions := projects.Options{ | ||
| Image: workspace.Config.Workspace.ProjectCloneConfig.Image, | ||
| Env: env.GetEnvironmentVariablesForProjectClone(workspace), | ||
| Resources: workspace.Config.Workspace.ProjectCloneConfig.Resources, | ||
| } | ||
| if workspace.Config.Workspace.ProjectCloneConfig.ImagePullPolicy != "" { | ||
| projectCloneOptions.PullPolicy = config.Workspace.ProjectCloneConfig.ImagePullPolicy | ||
| } else { | ||
| projectCloneOptions.PullPolicy = corev1.PullPolicy(config.Workspace.ImagePullPolicy) | ||
| } | ||
| if projectClone, err := projects.GetProjectCloneInitContainer(&workspace.Spec.Template, projectCloneOptions, workspace.Config.Routing.ProxyConfig); err != nil { | ||
| return r.failWorkspace(workspace, fmt.Sprintf("Failed to set up project-clone init container: %s", err), metrics.ReasonInfrastructureFailure, reqLogger, &reconcileStatus), nil | ||
| } else if projectClone != nil { | ||
| devfilePodAdditions.InitContainers = append([]corev1.Container{*projectClone}, devfilePodAdditions.InitContainers...) | ||
| } | ||
| } | ||
|
|
||
| // Inject operator-configured init containers | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.