Cancel active provisioning jobs when rolling back betas

This commit is contained in:
2026-10-05 17:48:46 -04:00
parent 6ad5e7f4c6
commit 701066aaf8
25 changed files with 564 additions and 37 deletions
+24
View File
@@ -535,3 +535,27 @@ describe('Watchdog provisioning and telemetry evidence', () => {
expect(await operation(rebuild.deploymentId)).toMatchObject({ state: 'done' });
});
});
describe('cancelling submitted legacy commands', () => {
it.each(['start', 'restart', 'stop'] as const)('ignores a late %s response after cancellation', async action => {
const { cancelProvisioningJob } = await import('../../src/lib/server/provisioning/cancellation.js');
const { processProvisioning } = await import('../../src/lib/server/provisioning/worker.js');
const { db } = await import('../../src/lib/server/db/index.js');
const komodo = await import('../../src/lib/server/integrations/komodo.js');
let release!: (value: { ok: true }) => void;
const command = action === 'restart' ? komodo.komodoRestart : komodo.komodoRuntimeAction;
vi.mocked(command).mockImplementationOnce(() => new Promise(resolve => { release = resolve; }));
const id = await queue(action);
const pending = processProvisioning();
await vi.waitFor(() => expect(release).toBeTypeOf('function'));
expect(cancelProvisioningJob(id)).toBe(true);
release({ ok: true });
await pending;
expect(await operation(id)).toMatchObject({ state: 'cancelled', stage: 'Cancelled by operator' });
expect(db().prepare('SELECT * FROM restart_rollout WHERE operation_id=?').all(id)).toEqual([]);
const replacement = await queue(action);
await processProvisioning();
expect(await operation(replacement)).toMatchObject({ state: 'awaiting-health' });
expect(command).toHaveBeenCalledTimes(2);
});
});