Skip to content

Commit

Permalink
[server][ws-manager] Allow setting customTimeoutAnnotation for headle…
Browse files Browse the repository at this point in the history
…ss workspace pods
  • Loading branch information
jankeromnes committed May 18, 2021
1 parent 04dae3f commit 2640e4c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
4 changes: 3 additions & 1 deletion components/server/src/workspace/workspace-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,9 @@ export class WorkspaceStarter {
spec.setWorkspaceImage(instance.workspaceImage);
spec.setWorkspaceLocation(workspace.config.workspaceLocation || spec.getCheckoutLocation());
spec.setFeatureFlagsList(this.toWorkspaceFeatureFlags(featureFlags));
spec.setTimeout(await userTimeoutPromise);
if (workspace.type === 'regular') {
spec.setTimeout(await userTimeoutPromise);
}
spec.setAdmission(admissionLevel);
return spec;
}
Expand Down
24 changes: 14 additions & 10 deletions components/ws-manager/pkg/manager/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,23 +731,27 @@ func (m *Manager) isWorkspaceTimedOut(wso workspaceObjects) (reason string, err
return decide(start, m.Config.Timeouts.TotalStartup, activity)

case api.WorkspacePhase_RUNNING:
var timeout util.Duration
if ctv, ok := wso.Pod.Annotations[customTimeoutAnnotation]; ok {
if ct, err := time.ParseDuration(ctv); err == nil {
timeout = util.Duration(ct)
} else {
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.")
if wso.IsWorkspaceHeadless() {
timeout = m.Config.Timeouts.HeadlessWorkspace
} else {
timeout = m.Config.Timeouts.RegularWorkspace
}
}
}
if wso.IsWorkspaceHeadless() {
return decide(start, m.Config.Timeouts.HeadlessWorkspace, activityRunningHeadless)
return decide(start, timeout, activityRunningHeadless)
} else if lastActivity == nil {
// the workspace is up and running, but the user has never produced any activity
return decide(start, m.Config.Timeouts.TotalStartup, activityNone)
} else if isClosed {
return decide(*lastActivity, m.Config.Timeouts.AfterClose, activityClosed)
}
timeout := m.Config.Timeouts.RegularWorkspace
if ctv, ok := wso.Pod.Annotations[customTimeoutAnnotation]; ok {
if ct, err := time.ParseDuration(ctv); err != nil {
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.")
timeout = m.Config.Timeouts.RegularWorkspace
} else {
timeout = util.Duration(ct)
}
}
return decide(*lastActivity, timeout, activityNone)

case api.WorkspacePhase_INTERRUPTED:
Expand Down

0 comments on commit 2640e4c

Please sign in to comment.