Skip to content

Commit 2640e4c

Browse files
committed
[server][ws-manager] Allow setting customTimeoutAnnotation for headless workspace pods
1 parent 04dae3f commit 2640e4c

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

components/server/src/workspace/workspace-starter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,9 @@ export class WorkspaceStarter {
633633
spec.setWorkspaceImage(instance.workspaceImage);
634634
spec.setWorkspaceLocation(workspace.config.workspaceLocation || spec.getCheckoutLocation());
635635
spec.setFeatureFlagsList(this.toWorkspaceFeatureFlags(featureFlags));
636-
spec.setTimeout(await userTimeoutPromise);
636+
if (workspace.type === 'regular') {
637+
spec.setTimeout(await userTimeoutPromise);
638+
}
637639
spec.setAdmission(admissionLevel);
638640
return spec;
639641
}

components/ws-manager/pkg/manager/status.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -731,23 +731,27 @@ func (m *Manager) isWorkspaceTimedOut(wso workspaceObjects) (reason string, err
731731
return decide(start, m.Config.Timeouts.TotalStartup, activity)
732732

733733
case api.WorkspacePhase_RUNNING:
734+
var timeout util.Duration
735+
if ctv, ok := wso.Pod.Annotations[customTimeoutAnnotation]; ok {
736+
if ct, err := time.ParseDuration(ctv); err == nil {
737+
timeout = util.Duration(ct)
738+
} else {
739+
log.WithError(err).WithField("customTimeout", ctv).WithFields(wsk8s.GetOWIFromObject(&wso.Pod.ObjectMeta)).Warn("pod had custom timeout annotation set, but could not parse its value. Defaulting to ws-manager config.")
740+
if wso.IsWorkspaceHeadless() {
741+
timeout = m.Config.Timeouts.HeadlessWorkspace
742+
} else {
743+
timeout = m.Config.Timeouts.RegularWorkspace
744+
}
745+
}
746+
}
734747
if wso.IsWorkspaceHeadless() {
735-
return decide(start, m.Config.Timeouts.HeadlessWorkspace, activityRunningHeadless)
748+
return decide(start, timeout, activityRunningHeadless)
736749
} else if lastActivity == nil {
737750
// the workspace is up and running, but the user has never produced any activity
738751
return decide(start, m.Config.Timeouts.TotalStartup, activityNone)
739752
} else if isClosed {
740753
return decide(*lastActivity, m.Config.Timeouts.AfterClose, activityClosed)
741754
}
742-
timeout := m.Config.Timeouts.RegularWorkspace
743-
if ctv, ok := wso.Pod.Annotations[customTimeoutAnnotation]; ok {
744-
if ct, err := time.ParseDuration(ctv); err != nil {
745-
log.WithError(err).WithField("customTimeout", ctv).WithFields(wsk8s.GetOWIFromObject(&wso.Pod.ObjectMeta)).Warn("pod had custom timeout annotation set, but could not parse its value. Defaulting to ws-manager config.")
746-
timeout = m.Config.Timeouts.RegularWorkspace
747-
} else {
748-
timeout = util.Duration(ct)
749-
}
750-
}
751755
return decide(*lastActivity, timeout, activityNone)
752756

753757
case api.WorkspacePhase_INTERRUPTED:

0 commit comments

Comments
 (0)