Skip to content

Commit 2b9fc36

Browse files
committed
Add annotation to enable diagnosing workspace start issues
Add annotation 'controller.devfile.io/debug-start' that disables the "stop workspace on failure" functionality. This is to make sure the workspace deployment stays on the cluster, allowing users to view logs and debug issues. Signed-off-by: Angel Misevski <[email protected]>
1 parent 1395cb5 commit 2b9fc36

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

controllers/workspace/devworkspace_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ func (r *DevWorkspaceReconciler) Reconcile(req ctrl.Request) (reconcileResult ct
125125

126126
// Stop failed workspaces
127127
if workspace.Status.Phase == devworkspacePhaseFailing && workspace.Spec.Started {
128+
// If debug annotation is present, leave the deployment in place to let users
129+
// view logs.
130+
if workspace.Annotations[constants.DevWorkspaceDebugStartAnnotation] == "true" {
131+
return reconcile.Result{}, nil
132+
}
133+
128134
patch := []byte(`{"spec":{"started": false}}`)
129135
err := r.Client.Patch(context.Background(), workspace, client.RawPatch(types.MergePatchType, patch))
130136
if err != nil {

pkg/constants/metadata.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ const (
4747
// this annotation will be cleared
4848
DevWorkspaceStopReasonAnnotation = "controller.devfile.io/stopped-by"
4949

50+
// DevWorkspaceDebugStartAnnotation enables debugging workspace startup if set to "true". If a workspace with this annotation
51+
// fails to start (i.e. enters the "Failed" phase), its deployment will not be scaled down in order to allow viewing logs, etc.
52+
DevWorkspaceDebugStartAnnotation = "controller.devfile.io/debug-start"
53+
5054
// WebhookRestartedAtAnnotation holds the the time (unixnano) of when the webhook server was forced to restart by controller
5155
WebhookRestartedAtAnnotation = "controller.devfile.io/restarted-at"
5256

0 commit comments

Comments
 (0)