Qfix default workspace mode (#6508)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2024-09-10 15:15:53 +04:00 committed by GitHub
parent 6784168b66
commit 7ad23c3443
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 4 deletions

View File

@ -1490,11 +1490,16 @@ export async function getPendingWorkspace (
operationQuery, operationQuery,
attemptsQuery, attemptsQuery,
region !== '' ? { region } : defaultRegionQuery, region !== '' ? { region } : defaultRegionQuery,
{ lastProcessingTime: { $lt: Date.now() - processingTimeoutMs } } {
$or: [
{ lastProcessingTime: { $exists: false } },
{ lastProcessingTime: { $lt: Date.now() - processingTimeoutMs } }
]
}
] ]
} }
return ( const result =
(await wsCollection.findOneAndUpdate( (await wsCollection.findOneAndUpdate(
query, query,
{ {
@ -1512,7 +1517,19 @@ export async function getPendingWorkspace (
} }
} }
)) ?? undefined )) ?? 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, workspace: BaseWorkspaceInfo,
opt: WorkspaceOptions opt: WorkspaceOptions
): Promise<void> { ): Promise<void> {
switch (workspace.mode) { switch (workspace.mode ?? 'active') {
case 'creating': case 'creating':
case 'pending-creation': case 'pending-creation':
// We need to either start workspace 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. // Seems we failed to delete, so let's restore deletion.
// TODO: move from account // TODO: move from account
break break
default:
ctx.error('Unknown workspace mode', { workspace: workspace.workspace, mode: workspace.mode })
} }
} }