uberf-8149: reset workspace attempts counter tool (#6604)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2024-09-17 14:33:39 +04:00 committed by GitHub
parent 434773d794
commit 9459fdecdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -524,7 +524,8 @@ export function devTool (
await updateWorkspace(db, info, {
mode: 'active',
progress: 100,
version
version,
attempts: 0
})
console.log(metricsToString(measureCtx.metrics, 'upgrade', 60))
@ -572,7 +573,8 @@ export function devTool (
await updateWorkspace(db, ws, {
mode: 'active',
progress: 100,
version
version,
attempts: 0
})
} catch (err: any) {
console.error(err)
@ -1589,6 +1591,25 @@ export function devTool (
})
})
program
.command('reset-ws-attempts <name>')
.description('Reset workspace creation/upgrade attempts counter')
.action(async (workspace) => {
const { mongodbUri } = prepareTools()
await withDatabase(mongodbUri, async (db) => {
const info = await getWorkspaceById(db, workspace)
if (info === null) {
throw new Error(`workspace ${workspace} not found`)
}
await updateWorkspace(db, info, {
attempts: 0
})
console.log('Attempts counter for workspace', workspace, 'has been reset')
})
})
extendProgram?.(program)
program.parse(process.argv)