Skip to content

Commit 9e07d3c

Browse files
authored
Backup prebuild logs even it's fail (#19808)
* Backup prebuild workspace even it's fail * skip backup content if headless task failed
1 parent c80ce48 commit 9e07d3c

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

components/ws-daemon/pkg/controller/workspace_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,10 @@ func (wsc *WorkspaceController) handleWorkspaceStop(ctx context.Context, ws *wor
298298
WorkspaceID: ws.Spec.Ownership.WorkspaceID,
299299
InstanceID: ws.Name,
300300
},
301-
SnapshotName: snapshotName,
302-
BackupLogs: ws.Spec.Type == workspacev1.WorkspaceTypePrebuild,
303-
UpdateGitStatus: ws.Spec.Type == workspacev1.WorkspaceTypeRegular,
301+
SnapshotName: snapshotName,
302+
BackupLogs: ws.Spec.Type == workspacev1.WorkspaceTypePrebuild,
303+
UpdateGitStatus: ws.Spec.Type == workspacev1.WorkspaceTypeRegular,
304+
SkipBackupContent: ws.Spec.Type == workspacev1.WorkspaceTypePrebuild && ws.IsConditionTrue(workspacev1.WorkspaceConditionsHeadlessTaskFailed),
304305
})
305306

306307
err = retry.RetryOnConflict(retryParams, func() error {

components/ws-daemon/pkg/controller/workspace_operations.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ type InitOptions struct {
9797
}
9898

9999
type BackupOptions struct {
100-
Meta WorkspaceMeta
101-
BackupLogs bool
102-
UpdateGitStatus bool
103-
SnapshotName string
100+
Meta WorkspaceMeta
101+
BackupLogs bool
102+
UpdateGitStatus bool
103+
SnapshotName string
104+
SkipBackupContent bool
104105
}
105106

106107
func NewWorkspaceOperations(config content.Config, provider *WorkspaceProvider, reg prometheus.Registerer) (WorkspaceOperations, error) {
@@ -237,6 +238,10 @@ func (wso *DefaultWorkspaceOperations) BackupWorkspace(ctx context.Context, opts
237238
}
238239
}
239240

241+
if opts.SkipBackupContent {
242+
return nil, nil
243+
}
244+
240245
err = wso.uploadWorkspaceContent(ctx, ws, opts.SnapshotName)
241246
if err != nil {
242247
glog.WithError(err).WithFields(ws.OWI()).Error("final backup failed for workspace")

components/ws-manager-mk2/controllers/status.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ func isDisposalFinished(ws *workspacev1.Workspace) bool {
276276
// Can't dispose if node disappeared.
277277
ws.IsConditionTrue(workspacev1.WorkspaceConditionNodeDisappeared) ||
278278
// Image builds have nothing to dispose.
279-
ws.Spec.Type == workspacev1.WorkspaceTypeImageBuild ||
280-
// headless workspaces that failed do not need to be backed up
281-
ws.IsConditionTrue(workspacev1.WorkspaceConditionsHeadlessTaskFailed)
279+
ws.Spec.Type == workspacev1.WorkspaceTypeImageBuild
282280
}
283281

284282
// extractFailure returns a pod failure reason and possibly a phase. If phase is nil then

0 commit comments

Comments
 (0)