Fix installs stuck as "Uninstalling"; remove a failed install's record

An uninstall whose export failed was cancelled, but its install stayed
"uninstalling" for good. It now goes back to live (or waiting for the
proxy), like a failed or hand-cancelled uninstall.

Uninstall is refused for a failed install (nothing of it is on the
server, so the export always failed) and for one still installing. A
failed install's page offers "Remove the record" instead, which also
clears records already stuck from before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 08:44:17 +02:00
co-authored by Claude Opus 5.5
parent 20c7146b0c
commit 915ae82416
4 changed files with 103 additions and 6 deletions
@@ -2,7 +2,7 @@
import React, { useCallback, useEffect, useState } from "react";
import Link from "next/link";
import { useParams, useSearchParams } from "next/navigation";
import { useParams, useRouter, useSearchParams } from "next/navigation";
import { api, errorText } from "@/lib/api";
import { bytes, fmtDate } from "@/lib/format";
import { Loading, Message, PageTitle } from "@/components/ui";
@@ -12,6 +12,7 @@ type Msg = { type: "ok" | "err"; text: string } | null;
type Detail = {
deployment: Deployment & { server: ServerSummary; jobs: Job[]; exports: { id: string; bytes: number; expiresAt: string; downloadedAt: string | null; deletedAt: string | null }[]; install: { version: string | null; url: string } | null };
fastPanel: string;
canRemoveRecord: boolean;
};
const H = 60 * 60 * 1000;
@@ -19,6 +20,7 @@ const H = 60 * 60 * 1000;
/** One install on a server: proxy, updates, adopt, uninstall (§7–9). */
export default function DeploymentPage() {
const { id } = useParams<{ id: string }>();
const router = useRouter();
const warn = useSearchParams().get("warn");
const [d, setD] = useState<Detail | null>(null);
const [msg, setMsg] = useState<Msg>(warn ? { type: "err", text: warn } : null);
@@ -48,6 +50,15 @@ export default function DeploymentPage() {
} catch (e) { setMsg({ type: "err", text: errorText(e) }); }
};
const removeRecord = async () => {
if (!d || !window.confirm(`Remove the record of ${d.deployment.shortName}? Its install failed, so nothing of it is on the server.`)) return;
setMsg(null);
try {
await api(`/api/admin/deployments/${id}`, { method: "DELETE" });
router.push("/servers/installs");
} catch (e) { setMsg({ type: "err", text: errorText(e) }); }
};
if (!d) return <div><ServersNav active="/servers/installs" />{msg ? <Message msg={msg} /> : <Loading />}</div>;
const x = d.deployment;
const minAt = upd.emergency ? 15 * 60 * 1000 : 4 * H;
@@ -117,7 +128,15 @@ export default function DeploymentPage() {
</div>
)}
{x.status !== "removed" && x.status !== "uninstalling" && (
{d.canRemoveRecord && (
<div className="card border-red-200">
<h2 className="font-medium text-red-800">Remove the record</h2>
<p className="mt-1 text-sm text-slate-500">This install failed and the server already removed what it made, so there&apos;s nothing to export or uninstall. Removing the record frees the short name.</p>
<button className="btn-danger mt-3" onClick={removeRecord}>Remove the record</button>
</div>
)}
{["live", "waiting_for_proxy"].includes(x.status) && (
<form className="card grid gap-3 border-red-200 md:grid-cols-3" onSubmit={e => { e.preventDefault(); if (window.confirm(`Uninstall ${x.shortName} on ${un.at.replace("T", " ")}? The church gets its data first.`)) act(`/api/admin/deployments/${x.id}/uninstall`, { at: fromInput(un.at), totp: un.totp, confirm: un.confirm }, "Uninstall planned: the site admin was emailed and sees a banner. The export runs first."); }}>
<h2 className="font-medium text-red-800 md:col-span-3">Uninstall</h2>
<p className="text-sm text-slate-500 md:col-span-3">At the time: the church&apos;s data is exported (encrypted; the link goes to the site admin), then the site, its tunnels and database are removed. The final backup stays on the server for 30 days.</p>