Skip to content

[server] Tone down log messages on startWorkspace #18720

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

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/server/src/jobs/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class JobRunner {
});
});
} catch (err) {
if (RedisMutex.isLockError(err)) {
if (RedisMutex.isLockedError(err)) {
log.debug(
`Failed to acquire lock for job ${job.name}. Likely another instance already holds the lock.`,
err,
Expand Down
9 changes: 7 additions & 2 deletions components/server/src/redis/mutex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ export class RedisMutex {
return this.client().using(resources, duration, settings, routine);
}

public static isLockError(err: any): boolean {
return err instanceof ResourceLockedError || err instanceof ExecutionError;
public static isLockedError(err: any): boolean {
return (
err instanceof ResourceLockedError ||
// Should be a ResourceLockedError as well, but is ExecutionError in v5.x: https://github.com/mike-marcacci/node-redlock/issues/168
(err instanceof ExecutionError &&
err.message.includes("unable to achieve a quorum during its retry window"))
);
}
}
8 changes: 4 additions & 4 deletions components/server/src/workspace/workspace-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,8 @@ export class WorkspaceStarter {
{ retryCount: 4, retryDelay: 500 }, // We wait at most 2s until we give up, and conclude that someone else is already starting this instance
)
.catch((err) => {
if (RedisMutex.isLockError(err)) {
log.warn({ instanceId }, "unable to acquire lock for workspace instance start");
return;
if (!RedisMutex.isLockedError(err)) {
log.warn({ instanceId }, "unexpected error during workspace instance start", err);
}
});
}
Expand Down Expand Up @@ -582,9 +581,10 @@ export class WorkspaceStarter {
// due to the reconciliation loop we might have already started the workspace, especially in the "pending" phase
const workspaceAlreadyExists = await this.existsWithWsManager(ctx, instance);
if (workspaceAlreadyExists) {
log.warn(
log.debug(
{ instanceId: instance.id, workspaceId: instance.workspaceId },
"workspace already exists, not starting again",
{ phase: instance.status.phase },
);
return;
}
Expand Down