-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[bridge] Marks stuck stopping and pending instances as stopped #13350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -452,7 +452,13 @@ export class WorkspaceManagerBridge implements Disposable { | |
|
||
// Control running workspace instances against ws-manager | ||
try { | ||
await this.controlNonStoppedWSManagerManagedInstances(ctx, nonStoppedInstances, clientProvider); | ||
await this.controlNonStoppedWSManagerManagedInstances( | ||
ctx, | ||
nonStoppedInstances, | ||
clientProvider, | ||
this.config.timeouts.pendingPhaseSeconds, | ||
this.config.timeouts.stoppingPhaseSeconds, | ||
); | ||
|
||
disconnectStarted = Number.MAX_SAFE_INTEGER; // Reset disconnect period | ||
} catch (err) { | ||
|
@@ -489,6 +495,8 @@ export class WorkspaceManagerBridge implements Disposable { | |
parentCtx: TraceContext, | ||
runningInstances: RunningWorkspaceInfo[], | ||
clientProvider: ClientProvider, | ||
pendingPhaseSeconds: number, | ||
stoppingPhaseSeconds: number, | ||
) { | ||
const installation = this.config.installation; | ||
|
||
|
@@ -508,36 +516,33 @@ export class WorkspaceManagerBridge implements Disposable { | |
for (const [instanceId, ri] of runningInstancesIdx.entries()) { | ||
const instance = ri.latestInstance; | ||
const phase = instance.status.phase; | ||
if (phase !== "running") { | ||
// This below if block is to validate the planned fix | ||
if ( | ||
phase === "pending" || | ||
phase === "creating" || | ||
phase === "initializing" || | ||
(phase === "stopping" && | ||
instance.stoppingTime && | ||
durationLongerThanSeconds(Date.parse(instance.stoppingTime), 10)) | ||
) { | ||
log.info( | ||
{ instanceId, workspaceId: instance.workspaceId }, | ||
"Logging to validate #12902. Should mark as stopped in database.", | ||
{ installation }, | ||
{ phase }, | ||
); | ||
} | ||
log.debug({ instanceId }, "Skipping instance", { | ||
phase: instance.status.phase, | ||
creationTime: instance.creationTime, | ||
region: instance.region, | ||
}); | ||
|
||
// When ws-manager is not aware of the following instances outside of the timeout duration, | ||
// they should be marked as stopped. | ||
// pending states timeout is 1 hour after creationTime. | ||
// stopping states timeout is 1 hour after stoppingTime. | ||
if ( | ||
phase === "running" || | ||
(phase === "pending" && | ||
durationLongerThanSeconds(Date.parse(instance.creationTime), pendingPhaseSeconds)) || | ||
(phase === "stopping" && | ||
instance.stoppingTime && | ||
durationLongerThanSeconds(Date.parse(instance.stoppingTime), stoppingPhaseSeconds)) | ||
) { | ||
log.info( | ||
{ instanceId, workspaceId: instance.workspaceId }, | ||
"Database says the instance is present, but ws-man does not know about it. Marking as stopped in database.", | ||
{ installation, phase }, | ||
); | ||
await this.markWorkspaceInstanceAsStopped(ctx, ri, new Date()); | ||
continue; | ||
} | ||
|
||
log.info( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @laushinka Sorry for the long turnaround. I like the new layout of the loop! But we need it to include this case: If an instance in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense that we should handle the |
||
"Database says the instance is running, but wsman does not know about it. Marking as stopped in database.", | ||
{ instanceId, workspaceId: instance.workspaceId, installation, phase }, | ||
); | ||
await this.markWorkspaceInstanceAsStopped(ctx, ri, new Date()); | ||
log.debug({ instanceId }, "Skipping instance", { | ||
phase: phase, | ||
creationTime: instance.creationTime, | ||
region: instance.region, | ||
}); | ||
} | ||
|
||
log.debug("Done controlling running instances.", { installation }); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.