-
Notifications
You must be signed in to change notification settings - Fork 67
feat(23570): Add controller for workspace backup #1530
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
Changes from all commits
1480c98
d1a8f94
b5bbebd
307145c
51b3eec
9b0ed96
c282a59
aa1053d
b99674a
9c41684
b0f56b3
4be0f98
c4a958c
2e99b7e
cbc61d8
afacdec
efe0538
3aba677
1e4e3fc
142a502
f083043
6433a76
191bec9
9d2b116
6af5fb8
ded04e9
094b3ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,47 @@ type CleanupCronJobConfig struct { | |
| Schedule string `json:"schedule,omitempty"` | ||
| } | ||
|
|
||
| type RegistryConfig struct { | ||
| // A registry where backup images are stored. Images are stored | ||
| // in {path}/${DEVWORKSPACE_NAMESPACE}/${DEVWORKSPACE_NAME}:latest | ||
| // +kubebuilder:validation:Required | ||
| Path string `json:"path,omitempty"` | ||
tolusha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // AuthSecret is the name of a Kubernetes secret of | ||
| // type kubernetes.io/dockerconfigjson. | ||
| // The secret is expected to be in the same namespace the workspace is running in. | ||
| // If secret is not found in the workspace namespace, the operator will look for the secret | ||
| // in the namespace where the operator is running in. | ||
| // as the DevWorkspaceOperatorCongfig. | ||
| // The secret must contain "controller.devfile.io/watch-secret=true" label so that it can be | ||
| // recognized by the operator. | ||
| // +kubebuilder:validation:Optional | ||
Allda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| AuthSecret string `json:"authSecret,omitempty"` | ||
Allda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| type OrasConfig struct { | ||
| // ExtraArgs are additional arguments passed to the oras CLI | ||
| // +kubebuilder:validation:Optional | ||
| ExtraArgs string `json:"extraArgs,omitempty"` | ||
Allda marked this conversation as resolved.
Show resolved
Hide resolved
tolusha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| type BackupCronJobConfig struct { | ||
tolusha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Enable determines whether backup CronJobs should be created for workspace PVCs. | ||
| // Defaults to false if not specified. | ||
| // +kubebuilder:validation:Optional | ||
| Enable *bool `json:"enable,omitempty"` | ||
rohanKanojia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // RegistryConfig defines the registry configuration where backup images are stored. | ||
| // +kubebuilder:validation:Required | ||
| Registry *RegistryConfig `json:"registry,omitempty"` | ||
| // OrasConfig defines additional configuration options for the oras CLI used to | ||
| // push and pull backup images. | ||
| OrasConfig *OrasConfig `json:"oras,omitempty"` | ||
| // Schedule specifies the cron schedule for the backup cron job. | ||
| // For example, "0 1 * * *" runs daily at 1 AM. | ||
| // +kubebuilder:default:="0 1 * * *" | ||
| // +kubebuilder:validation:Optional | ||
| Schedule string `json:"schedule,omitempty"` | ||
| } | ||
|
|
||
| type RoutingConfig struct { | ||
| // DefaultRoutingClass specifies the routingClass to be used when a DevWorkspace | ||
| // specifies an empty `.spec.routingClass`. Supported routingClasses can be defined | ||
|
|
@@ -189,6 +230,8 @@ type WorkspaceConfig struct { | |
| RuntimeClassName *string `json:"runtimeClassName,omitempty"` | ||
| // CleanupCronJobConfig defines configuration options for a cron job that automatically cleans up stale DevWorkspaces. | ||
| CleanupCronJob *CleanupCronJobConfig `json:"cleanupCronJob,omitempty"` | ||
| // BackupCronJobConfig defines configuration options for a cron job that automatically backs up workspace PVCs. | ||
| BackupCronJob *BackupCronJobConfig `json:"backupCronJob,omitempty"` | ||
| // PostStartTimeout defines the maximum duration the PostStart hook can run | ||
| // before it is automatically failed. This timeout is used for the postStart lifecycle hook | ||
| // that is used to run commands in the workspace container. The timeout is specified in seconds. | ||
|
|
@@ -331,14 +374,26 @@ type ConfigmapReference struct { | |
| Namespace string `json:"namespace"` | ||
| } | ||
|
|
||
| type OperatorConfigurationStatus struct { | ||
| // Conditions represent the latest available observations of the OperatorConfiguration's state | ||
| Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
| // LastBackupTime is the timestamp of the last successful backup. Nil if | ||
| // no backup is configured or no backup has yet succeeded. | ||
| LastBackupTime *metav1.Time `json:"lastBackupTime,omitempty"` | ||
|
Contributor
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. Is it time when backup is started or finished?
Collaborator
Author
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. This value is used to determine whether a workspace was stopped after the last backup cron run. We don't want to do a backup of a workspace if it already has a valid backup and it is still stopped. I compare this timestamp with the time when the workspace was stopped, and based on that, I determine if the backup is necessary.
Contributor
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. If it is related to a specific workspace, then how do we handle multiple of them?
Collaborator
Author
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. It is specific to a whole cluster as it is defined on operator config level, not individual workspaces. This value tracks when the last cron job was executed, not the backup Job itself. And using this value, we are able to determine if the workspace was stopped after the last round and needs a backup.
Contributor
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. cc @dkwon17
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. I thought about it a bit more, maybe the backup job pod can update the DW with an annotation with backup time if the backup and push to registry was both successful? Since it would let DWO know which DevWorkspaces have successfully backed up or not. From the user/admin perspective, I guess they could also view the image registry to tell which were successfully backed up. Maybe it can be done in a different PR though, IMHO I don't think it's crucial right now cc @cgruver @ibuziuk
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. A benefit I see of having an annotation set to each DW, is in this scenario:
If the DWO knew which DevWorkspaces were successfully/unsucessfully backed up, DWO would be able to know that
Contributor
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. annotation with backup time is a very good idea, smth. similar to idling - could be done as a separate PR though |
||
| } | ||
|
|
||
| // DevWorkspaceOperatorConfig is the Schema for the devworkspaceoperatorconfigs API | ||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:resource:path=devworkspaceoperatorconfigs,scope=Namespaced,shortName=dwoc | ||
| type DevWorkspaceOperatorConfig struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Config *OperatorConfiguration `json:"config,omitempty"` | ||
| // Status represents the current status of the DevWorkspaceOperatorConfig | ||
| // automatically managed by the DevWorkspace Operator. | ||
| Status *OperatorConfigurationStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // DevWorkspaceOperatorConfigList contains a list of DevWorkspaceOperatorConfig | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.