Skip to content

Commit e74a946

Browse files
author
Laurie T. Malau
committed
Stops stuck workspaces
1 parent 8dcbb57 commit e74a946

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

components/ws-manager-bridge/src/bridge.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ export class WorkspaceManagerBridge implements Disposable {
436436
clientProvider: ClientProvider,
437437
controllerIntervalSeconds: number,
438438
controllerMaxDisconnectSeconds: number,
439+
maxTimeToRunningPhaseSeconds = 60 * 60,
439440
) {
440441
let disconnectStarted = Number.MAX_SAFE_INTEGER;
441442
this.disposables.push(
@@ -452,7 +453,12 @@ export class WorkspaceManagerBridge implements Disposable {
452453

453454
// Control running workspace instances against ws-manager
454455
try {
455-
await this.controlRunningInstances(ctx, runningInstances, clientProvider);
456+
await this.controlRunningInstances(
457+
ctx,
458+
runningInstances,
459+
clientProvider,
460+
maxTimeToRunningPhaseSeconds,
461+
);
456462

457463
disconnectStarted = Number.MAX_SAFE_INTEGER; // Reset disconnect period
458464
} catch (err) {
@@ -489,6 +495,7 @@ export class WorkspaceManagerBridge implements Disposable {
489495
parentCtx: TraceContext,
490496
runningInstances: RunningWorkspaceInfo[],
491497
clientProvider: ClientProvider,
498+
maxTimeToRunningPhaseSeconds: number,
492499
) {
493500
const installation = this.config.installation;
494501

@@ -506,7 +513,10 @@ export class WorkspaceManagerBridge implements Disposable {
506513

507514
for (const [instanceId, ri] of runningInstancesIdx.entries()) {
508515
const instance = ri.latestInstance;
509-
if (instance.status.phase !== "running") {
516+
if (
517+
instance.status.phase === "pending" &&
518+
durationLongerThanSeconds(Date.parse(instance.creationTime), maxTimeToRunningPhaseSeconds)
519+
) {
510520
log.debug({ instanceId }, "Skipping instance", {
511521
phase: instance.status.phase,
512522
creationTime: instance.creationTime,

0 commit comments

Comments
 (0)