Merge remote-tracking branch 'origin/develop' into staging

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-09-10 18:19:51 +07:00
commit 390765f560
No known key found for this signature in database
GPG Key ID: BD80F68D68D8F7F2
2 changed files with 23 additions and 4 deletions

View File

@ -1490,11 +1490,16 @@ export async function getPendingWorkspace (
operationQuery,
attemptsQuery,
region !== '' ? { region } : defaultRegionQuery,
{ lastProcessingTime: { $lt: Date.now() - processingTimeoutMs } }
{
$or: [
{ lastProcessingTime: { $exists: false } },
{ lastProcessingTime: { $lt: Date.now() - processingTimeoutMs } }
]
}
]
}
return (
const result =
(await wsCollection.findOneAndUpdate(
query,
{
@ -1512,7 +1517,19 @@ export async function getPendingWorkspace (
}
}
)) ?? undefined
)
if (result != null) {
ctx.info('getPendingWorkspace', {
workspaceId: result.workspace,
mode: result.mode,
workspaceName: result.workspaceName,
operation,
region,
version
})
}
return result
}
/**

View File

@ -220,7 +220,7 @@ export class WorkspaceWorker {
workspace: BaseWorkspaceInfo,
opt: WorkspaceOptions
): Promise<void> {
switch (workspace.mode) {
switch (workspace.mode ?? 'active') {
case 'creating':
case 'pending-creation':
// We need to either start workspace creation
@ -237,6 +237,8 @@ export class WorkspaceWorker {
// Seems we failed to delete, so let's restore deletion.
// TODO: move from account
break
default:
ctx.error('Unknown workspace mode', { workspace: workspace.workspace, mode: workspace.mode })
}
}