Broken Docker containers are alerts
From Dockhand, on the health pass: a container that keeps restarting (critical, with its exit code), one whose own health check fails, one that stopped unexpectedly, one created and never started for an hour, and a Docker host Dockhand cannot reach. A stop is only news when it was seen happen, so stacks switched off long ago stay quiet. A Leave alone button on the Docker page and a list in Settings; on by default. Also fixes a date-dependent storage-forecast test that pinned its clock while the code under test reads the real one. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
16b24f5436
commit
0fa50c2d5a
20 files changed
+659
-17
No files matched your search
@@ -32,6 +32,17 @@ function updateBadge(c: DockhandContainer) {
|
||||
);
|
||||
}
|
||||
|
||||
/** What is wrong with a container, in a badge: the same finding the health pass raises an alert for. */
|
||||
function problemBadge(c: DockhandContainer) {
|
||||
if (c.leftAlone) return <span className="badge bg-secondary-lt text-secondary" title="No alert is raised for it">left alone</span>;
|
||||
if (!c.problem) return null;
|
||||
return (
|
||||
<span className={`badge ${c.problem.severity === "critical" ? "bg-red-lt text-red" : "bg-yellow-lt text-yellow"}`} title={`An alert is raised: ${c.name} ${c.problem.text}`}>
|
||||
{c.problem.kind === "restarting" ? "restart loop" : c.problem.kind === "unhealthy" ? "unhealthy" : c.problem.kind === "created" ? "never started" : "stopped unexpectedly"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function containerStateBadge(state: string) {
|
||||
switch (state) {
|
||||
case "running":
|
||||
@@ -95,6 +106,17 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [selectedId]);
|
||||
|
||||
async function leaveAlone(c: DockhandContainer) {
|
||||
if (!selected) return;
|
||||
try {
|
||||
await api.integrations.dockhand.leaveAlone(selected.id, c.environmentName, c.name, !c.leftAlone);
|
||||
toast.success(c.leftAlone ? `Watching ${c.name} again.` : `Leaving ${c.name} alone — no alerts for it.`);
|
||||
loadContainers(selected.id);
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : String(err));
|
||||
}
|
||||
}
|
||||
|
||||
const hosts = [...new Set((data?.containers ?? []).map((c) => c.environmentName))].sort();
|
||||
const filteredContainers = (data?.containers ?? []).filter((c) => !hostFilter || c.environmentName === hostFilter);
|
||||
|
||||
@@ -189,6 +211,13 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
) : (
|
||||
<div className="card">
|
||||
{data?.unreachable && data.unreachable.length > 0 && (
|
||||
<div className="alert alert-warning m-3 mb-0" role="status">
|
||||
<div>
|
||||
Dockhand can’t reach {data.unreachable.map((u) => `${u.environmentName} (${u.error})`).join(", ")} — those hosts’ containers are missing from this list.
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">
|
||||
Containers
|
||||
@@ -197,6 +226,9 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
||||
{data.summary.running}/{data.summary.total} running
|
||||
</span>
|
||||
)}
|
||||
{data && data.containers.filter((c) => c.problem && !c.leftAlone).length > 0 && (
|
||||
<span className="text-red fw-normal ms-2">{data.containers.filter((c) => c.problem && !c.leftAlone).length} with a problem</span>
|
||||
)}
|
||||
{data && data.containers.filter((c) => c.updateAvailable).length > 0 && (
|
||||
<span className="text-yellow fw-normal ms-2">
|
||||
{data.containers.filter((c) => c.updateAvailable).length} update(s) available
|
||||
@@ -270,7 +302,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
||||
<td className="text-secondary text-break">{c.environmentName}</td>
|
||||
<td className="text-secondary text-break">{c.image}</td>
|
||||
<td>
|
||||
{containerStateBadge(c.state)}
|
||||
{containerStateBadge(c.state)} {problemBadge(c)}
|
||||
<div className="text-secondary small">{c.status}</div>
|
||||
</td>
|
||||
<td>{updateBadge(c)}</td>
|
||||
@@ -303,6 +335,11 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
||||
Start
|
||||
</button>
|
||||
)}
|
||||
{user.role === "admin" && (c.problem || c.leftAlone) && (
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={() => void leaveAlone(c)} title={c.leftAlone ? "Raise alerts about it again" : "Stop raising alerts about this container"}>
|
||||
{c.leftAlone ? "Watch again" : "Leave alone"}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
)}
|
||||
|
||||
@@ -84,7 +84,7 @@ const DIGEST_DAYS: { value: number; label: string }[] = [
|
||||
{ value: 6, label: "Saturday" },
|
||||
{ value: 0, label: "Sunday" },
|
||||
];
|
||||
const DEFAULT_HEALTH_CHECKS: HealthCheckSettings = { serverOfflineMinutes: 60, diskUsagePercent: 90, domainWarnDays: 30, diskForecastDays: 14, backupStaleHours: 48, restoreTestDays: 0, newPortAlerts: true, flapRaises: 3, deviceOfflineMinutes: 10, osSupportWarnDays: 90, baselineAlerts: true };
|
||||
const DEFAULT_HEALTH_CHECKS: HealthCheckSettings = { serverOfflineMinutes: 60, diskUsagePercent: 90, domainWarnDays: 30, diskForecastDays: 14, backupStaleHours: 48, restoreTestDays: 0, newPortAlerts: true, flapRaises: 3, deviceOfflineMinutes: 10, osSupportWarnDays: 90, baselineAlerts: true, containerAlerts: true, containerIgnore: [] };
|
||||
const DEFAULT_MONTHLY: MonthlyReportSettings = { enabled: false, quarterly: false, annual: false, day: 1, time: "08:00" };
|
||||
|
||||
type TestResult = { ok: boolean; message: string } | null;
|
||||
@@ -841,6 +841,30 @@ export default function NotificationSettings() {
|
||||
/>
|
||||
{toggle("pbsVerificationCheck", "Proxmox Backup Server snapshot failed verification")}
|
||||
{toggle("dockerUpdateCheck", "Docker image update available")}
|
||||
<label className="form-check mt-3 mb-0">
|
||||
<input type="checkbox" className="form-check-input" checked={healthChecks.containerAlerts} onChange={(e) => setHealthChecks((h) => ({ ...h, containerAlerts: e.target.checked }))} />
|
||||
<span className="form-check-label">
|
||||
Warn when a Docker container is broken
|
||||
<span className="form-hint d-block">
|
||||
From Dockhand, on the same pass as the server checks: a container that keeps restarting (critical), one whose own health check fails, one that stopped when it was not meant to
|
||||
(it was running at the last look, or stopped within the day), one created and never started for an hour, and a Docker host Dockhand cannot reach. A container that has been stopped all along is
|
||||
left alone.
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<label className="form-label mt-2" htmlFor="container-ignore">
|
||||
Containers to leave alone
|
||||
</label>
|
||||
<textarea
|
||||
id="container-ignore"
|
||||
className="form-control"
|
||||
rows={3}
|
||||
disabled={!healthChecks.containerAlerts}
|
||||
placeholder={"one per line: a name, or host/name — * stands for anything\nplanka-*\nSiri/drawio"}
|
||||
value={healthChecks.containerIgnore.join("\n")}
|
||||
onChange={(e) => setHealthChecks((h) => ({ ...h, containerIgnore: e.target.value.split("\n").map((l) => l.trim()).filter(Boolean) }))}
|
||||
/>
|
||||
<div className="form-hint">The scanner containers Dockhand starts (dockhand-grype-*, dockhand-trivy-*) are always left alone. There is also a <em>Leave alone</em> button on the Docker page.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user