-
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?
Conversation
The function will be used across both backup and restore features and should be accessed multiple places. Signed-off-by: Ales Raszka <[email protected]>
A new init container is added to the workspace deployment in case user choose to restore the workspace from backup. By setting workspace attribute "controller.devfile.io/restore-workspace" the controller sets a new init container instead of cloning data from git repository. By default an automated path to restore image is used based on cluster settings. However user is capable overwrite that value using another attribute "controller.devfile.io/restore-source-image". The restore container runs a wokspace-recovery.sh script that pull an image using oras an extract files to a /project directory. Signed-off-by: Ales Raszka <[email protected]>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Allda The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| return nil | ||
| } | ||
|
|
||
| func GetErnvinmentVariablesForProjectRestore(workspace *common.DevWorkspaceWithConfig) []corev1.EnvVar { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func GetErnvinmentVariablesForProjectRestore(workspace *common.DevWorkspaceWithConfig) []corev1.EnvVar { | |
| func GetEnvironmentVariablesForProjectRestore(workspace *common.DevWorkspaceWithConfig) []corev1.EnvVar { |
| {Name: "BACKUP_IMAGE", Value: restoreSourceImage}, | ||
| }...) | ||
|
|
||
| return &corev1.Container{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need some default resources specified for this container
| } | ||
|
|
||
| // Add init container to clone projects only if restore container wasn't created | ||
| if !workspaceRestoreCreated { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate please, why do we need fall back on this?
cc @dkwon17
| ) (*corev1.Container, error) { | ||
| wokrspaceTempplate := &workspace.Spec.Template | ||
| // Check if restore is requested via workspace attribute | ||
| if !wokrspaceTempplate.Attributes.Exists(constants.WorkspaceRestoreAttribute) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO I think it would be more readable if this check was done by the caller in devworkspace_controller.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the example presented in the Is it tested? How? section of this PR, the example has:
controller.devfile.io/restore-workspace: 'true'
which made me assume that:
controller.devfile.io/restore-workspace: 'false'
would disable the restore functionality for the devworkspace.
Could we also check for "false" string here?
| @@ -0,0 +1,65 @@ | |||
| // | |||
| // Copyright (c) 2019-2025 Red Hat, Inc. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Copyright (c) 2019-2025 Red Hat, Inc. | |
| // Copyright (c) 2019-2026 Red Hat, Inc. |
| @@ -0,0 +1,129 @@ | |||
| // | |||
| // Copyright (c) 2019-2025 Red Hat, Inc. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Copyright (c) 2019-2025 Red Hat, Inc. | |
| // Copyright (c) 2019-2026 Red Hat, Inc. |
| // from the DevWorkspace | ||
| BootstrapDevWorkspaceAttribute = "controller.devfile.io/bootstrap-devworkspace" | ||
|
|
||
| // WorkspaceRestoreAttribute defines whether workspace restore should be performed when creating a DevWorkspace. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // WorkspaceRestoreAttribute defines whether workspace restore should be performed when creating a DevWorkspace. | |
| // WorkspaceRestoreAttribute defines whether workspace restore should be performed for a DevWorkspace. |
Small suggestion
What does this PR do?
Add init container for workspace restoration
A new init container is added to the workspace deployment in case user choose to restore the workspace from backup.
By setting the workspace attribute "controller.devfile.io/restore-workspace" the controller sets a new init container instead of cloning data from git repository.
By default an automated path to restore image is used based on cluster settings. However user is capable overwrite that value using another attribute "controller.devfile.io/restore-source-image".
The restore container runs a wokspace-recovery.sh script that pull an image using oras an extract files to a /project directory.
What issues does this PR fix or reference?
#1525
Is it tested? How?
No automated tests are available in the first phase. I will add tests once I get the first approval that the concept is ok.
How to test:
kubectl delete devworkspace restore-workspace-2controller.devfile.io/restore-workspace)PR Checklist
/test v8-devworkspace-operator-e2e, v8-che-happy-pathto trigger)v8-devworkspace-operator-e2e: DevWorkspace e2e testv8-che-happy-path: Happy path for verification integration with CheWhat's missing: