Skip to content

Commit 1ae156c

Browse files
author
Laurie T. Malau
committed
[bridge] Mark as stopped pending and stopping
1 parent dbb182a commit 1ae156c

File tree

14 files changed

+65
-49
lines changed

14 files changed

+65
-49
lines changed

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

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -508,36 +508,39 @@ export class WorkspaceManagerBridge implements Disposable {
508508
for (const [instanceId, ri] of runningInstancesIdx.entries()) {
509509
const instance = ri.latestInstance;
510510
const phase = instance.status.phase;
511-
if (phase !== "running") {
512-
// This below if block is to validate the planned fix
513-
if (
514-
phase === "pending" ||
515-
phase === "creating" ||
516-
phase === "initializing" ||
517-
(phase === "stopping" &&
518-
instance.stoppingTime &&
519-
durationLongerThanSeconds(Date.parse(instance.stoppingTime), 10))
520-
) {
521-
log.info(
522-
{ instanceId, workspaceId: instance.workspaceId },
523-
"Logging to validate #12902. Should mark as stopped in database.",
524-
{ installation },
525-
{ phase },
526-
);
527-
}
528-
log.debug({ instanceId }, "Skipping instance", {
529-
phase: instance.status.phase,
530-
creationTime: instance.creationTime,
531-
region: instance.region,
532-
});
511+
512+
// When ws-manager is not aware of the following instances outside of the timeout duration,
513+
// they should be marked as stopped.
514+
// pending states timeout is 1 hour after creationTime.
515+
// stopping states timeout is 1 hour after stoppingTime.
516+
if (
517+
(phase === "pending" &&
518+
durationLongerThanSeconds(
519+
Date.parse(instance.creationTime),
520+
this.config.timeouts.maxInstanceDuration,
521+
)) ||
522+
(phase === "stopping" &&
523+
instance.stoppingTime &&
524+
durationLongerThanSeconds(
525+
Date.parse(instance.stoppingTime),
526+
this.config.timeouts.maxInstanceDuration,
527+
))
528+
) {
529+
log.info(
530+
{ instanceId, workspaceId: instance.workspaceId },
531+
"Database says the instance is running, but ws-man does not know about it. Marking as stopped in database.",
532+
{ installation },
533+
{ phase },
534+
);
535+
await this.markWorkspaceInstanceAsStopped(ctx, ri, new Date());
533536
continue;
534537
}
535538

536-
log.info(
537-
"Database says the instance is running, but wsman does not know about it. Marking as stopped in database.",
538-
{ instanceId, workspaceId: instance.workspaceId, installation, phase },
539-
);
540-
await this.markWorkspaceInstanceAsStopped(ctx, ri, new Date());
539+
log.debug({ instanceId }, "Skipping instance", {
540+
phase: phase,
541+
creationTime: instance.creationTime,
542+
region: instance.region,
543+
});
541544
}
542545

543546
log.debug("Done controlling running instances.", { installation });

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface Configuration {
3131
preparingPhaseSeconds: number;
3232
buildingPhaseSeconds: number;
3333
unknownPhaseSeconds: number;
34+
maxInstanceDuration: number;
3435
};
3536

3637
// emulatePreparingIntervalSeconds configures how often we check for Workspaces in phase "preparing" for clusters we do not govern

install/installer/cmd/testdata/render/aws-setup/output.golden

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/installer/cmd/testdata/render/azure-setup/output.golden

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/installer/cmd/testdata/render/customization/output.golden

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/installer/cmd/testdata/render/external-registry/output.golden

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/installer/cmd/testdata/render/gcp-setup/output.golden

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/installer/cmd/testdata/render/http-proxy/output.golden

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/installer/cmd/testdata/render/insecure-s3-setup/output.golden

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/installer/cmd/testdata/render/minimal/output.golden

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/installer/cmd/testdata/render/statefulset-customization/output.golden

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/installer/cmd/testdata/render/use-pod-security-policies/output.golden

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/installer/cmd/testdata/render/workspace-requests-limits/output.golden

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/installer/pkg/components/ws-manager-bridge/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Timeouts struct {
2626
PreparingPhaseSeconds int32 `json:"preparingPhaseSeconds"`
2727
BuildingPhaseSeconds int32 `json:"buildingPhaseSeconds"`
2828
UnknownPhaseSeconds int32 `json:"unknownPhaseSeconds"`
29+
MaxInstanceDuration int32 `json:"maxInstanceDuration"`
2930
}
3031

3132
// WorkspaceCluster from components/gitpod-protocol/src/workspace-cluster.ts

0 commit comments

Comments
 (0)