Add cancellation and cleanup for native server creation

This commit is contained in:
2026-10-04 18:00:11 -04:00
parent 19f1f4e279
commit 176b7dd86b
17 changed files with 482 additions and 26 deletions
@@ -1,7 +1,14 @@
import { json } from '@sveltejs/kit';
import { cancelRemoval } from '$lib/server/provisioning/index.js';
import { cancelRemoval } from '$lib/server/provisioning/history.js';
import { cancelCreation } from '$lib/server/provisioning/cancel-creation.js';
import { kickProvisioning } from '$lib/server/pipeline/worker.js';
export function POST({ params }: { params: { id: string } }) {
if (!cancelRemoval(params.id)) return json({ error: 'Removal has already begun or this request is no longer waiting. Refresh to see its current state.' }, { status: 409 });
const cleanupId = cancelCreation(params.id);
if (cleanupId) {
void kickProvisioning();
return json({ ok: true, cleanupId });
}
if (!cancelRemoval(params.id)) return json({ error: 'This operation can no longer be cancelled. Refresh to see its current state.' }, { status: 409 });
return json({ ok: true });
}