feat(releaseupdate): judge the installed release, window from install (#1725)
The canary window now counts from when a release is installed on the host (installed.json / installed_at in the update snapshot), not from the statement's issued_at, and 'release canary check' judges the release the canary actually runs via its exact-pin tag instead of the moving next tag. A newer release on next queues behind the one being judged instead of restarting the clock, so stable moves once per release. New subcommands: canary status (read-only state, signals, verdict), canary promote (promote now when hard checks pass), canary unpin (back to next), and start -force. A held/pinned canary is verified installable every check and a stranded pin fails the run red instead of looking green. Rollback pre-flight checks stable's zip and agent image digests before pinning. Relative signals are judged whenever both windows carry minimum data, so a breach rolls back mid-window; promote still needs the full window unless the operator promotes early (new promote.yml workflow_dispatch). The window is configurable via -window / CANARY_WINDOW. Also: dashboard canary status card (ui), and task canary:rehearse, a local end-to-end rehearsal of publish -> canary start -> status -> check -> promote against a throwaway registry and host. task check passes; rehearsal run green (REHEARSE_EXIT=0).
This commit is contained in:
18 files changed
+1487
-180
No files matched your search
@@ -0,0 +1,184 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { MetadataList } from "@/components/ui/metadata-list";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { ApiError, api } from "@/lib/api";
|
||||
import { useSettingsStore } from "@/stores/settings";
|
||||
|
||||
/**
|
||||
* The release canary on this host, read-only: the update settings in force,
|
||||
* the installed release, how long it has been installed and how far through
|
||||
* the default canary window that is. Installing and promoting releases run
|
||||
* in the update UI and CI, not here.
|
||||
*/
|
||||
|
||||
// The wire shape of GET /api/chat/update: Go's default field names, except
|
||||
// installed_at, which the server tags. Zero time means no install recorded.
|
||||
interface UpdateComponent {
|
||||
ID: string;
|
||||
Label: string;
|
||||
Installed: string;
|
||||
Available: string;
|
||||
Reference?: string;
|
||||
Changelog?: string;
|
||||
}
|
||||
|
||||
interface UpdateSnapshot {
|
||||
Components: UpdateComponent[];
|
||||
Deferred?: boolean;
|
||||
installed_at?: string;
|
||||
}
|
||||
|
||||
interface ChatUpdate {
|
||||
snapshot: UpdateSnapshot;
|
||||
available: UpdateComponent[] | null;
|
||||
can_install: boolean;
|
||||
}
|
||||
|
||||
interface UpdateSettings {
|
||||
channel?: string;
|
||||
pin?: string;
|
||||
}
|
||||
|
||||
// The default window a release runs on the canary before it can be promoted,
|
||||
// mirroring releaseupdate.CanaryWindow on the server.
|
||||
const CANARY_WINDOW_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
const KIND = "update-settings";
|
||||
|
||||
const store = useSettingsStore();
|
||||
const update = ref<ChatUpdate | null>(null);
|
||||
const notConfigured = ref(false);
|
||||
const loading = ref(true);
|
||||
const error = ref<string | null>(null);
|
||||
const now = ref(Date.now());
|
||||
let timer: ReturnType<typeof setInterval> | undefined;
|
||||
let alive = true;
|
||||
|
||||
const settings = computed(() => (store.stateFor(KIND).resource?.value ?? {}) as UpdateSettings);
|
||||
const channel = computed(() => settings.value.channel || "stable");
|
||||
const pin = computed(() => settings.value.pin || "");
|
||||
const pinned = computed(() => channel.value === "exact-pin");
|
||||
|
||||
const channelLabel: Record<string, string> = {
|
||||
stable: "Stable",
|
||||
next: "Prereleases",
|
||||
"exact-pin": "Pinned",
|
||||
};
|
||||
|
||||
const daemon = computed(() => update.value?.snapshot.Components.find((c) => c.ID === "daemon"));
|
||||
const available = computed(() => update.value?.available ?? []);
|
||||
|
||||
const installedAt = computed(() => {
|
||||
const raw = update.value?.snapshot.installed_at;
|
||||
if (!raw) return null;
|
||||
const at = new Date(raw);
|
||||
// The zero time serialises as year 1: no install was recorded.
|
||||
if (Number.isNaN(at.getTime()) || at.getFullYear() <= 1) return null;
|
||||
return at;
|
||||
});
|
||||
const elapsedMs = computed(() =>
|
||||
installedAt.value ? Math.max(0, now.value - installedAt.value.getTime()) : null,
|
||||
);
|
||||
const windowProgress = computed(() =>
|
||||
elapsedMs.value == null ? null : Math.min(100, (elapsedMs.value / CANARY_WINDOW_MS) * 100),
|
||||
);
|
||||
const elapsedText = computed(() => (elapsedMs.value == null ? "" : elapsed(elapsedMs.value)));
|
||||
|
||||
function elapsed(ms: number): string {
|
||||
const totalMinutes = Math.floor(ms / 60_000);
|
||||
const days = Math.floor(totalMinutes / 1440);
|
||||
const hours = Math.floor((totalMinutes % 1440) / 60);
|
||||
const minutes = totalMinutes % 60;
|
||||
if (days) return `${days}d ${hours}h`;
|
||||
if (hours) return `${hours}h ${minutes}m`;
|
||||
return `${minutes}m`;
|
||||
}
|
||||
|
||||
const rows = computed(() => {
|
||||
const list: { label: string; value?: string; mono?: boolean }[] = [
|
||||
{ label: "Channel", value: channelLabel[channel.value] ?? channel.value },
|
||||
{ label: "Installed", value: daemon.value?.Installed || "unknown", mono: true },
|
||||
{ label: "Installed at", value: installedAt.value ? "" : "not recorded" },
|
||||
{
|
||||
label: "Available",
|
||||
value: available.value.length
|
||||
? available.value.map((c) => `${c.Label || c.ID} ${c.Installed} → ${c.Available}`).join(", ")
|
||||
: "none",
|
||||
mono: true,
|
||||
},
|
||||
];
|
||||
return list;
|
||||
});
|
||||
|
||||
async function load(): Promise<void> {
|
||||
loading.value = true;
|
||||
error.value = null;
|
||||
try {
|
||||
const fresh = await api.updateSnapshot<ChatUpdate>();
|
||||
if (!alive) return;
|
||||
update.value = fresh;
|
||||
notConfigured.value = false;
|
||||
} catch (err) {
|
||||
if (!alive) return;
|
||||
if (err instanceof ApiError && err.status === 501) {
|
||||
notConfigured.value = true;
|
||||
update.value = null;
|
||||
} else {
|
||||
error.value = err instanceof Error ? err.message : String(err);
|
||||
}
|
||||
} finally {
|
||||
if (alive) loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void store.load();
|
||||
void load();
|
||||
timer = setInterval(() => {
|
||||
now.value = Date.now();
|
||||
void load();
|
||||
}, 15_000);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
alive = false;
|
||||
if (timer) clearInterval(timer);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Section title="Release canary">
|
||||
<p v-if="notConfigured" class="text-sm text-fg-muted">Update checks not configured.</p>
|
||||
<template v-else>
|
||||
<p v-if="error" class="text-sm text-danger">{{ error }}</p>
|
||||
<p v-else-if="loading && !update" class="text-sm text-fg-muted">Checking…</p>
|
||||
<template v-else>
|
||||
<MetadataList :rows="rows">
|
||||
<template #value="{ row }">
|
||||
<template v-if="row.label === 'Channel' && pinned">
|
||||
<Badge variant="danger" class="mr-2">held</Badge>
|
||||
<span class="font-mono">{{ pin }}</span>
|
||||
</template>
|
||||
<template v-else-if="row.label === 'Installed at' && installedAt">
|
||||
<Timestamp :at="installedAt" /> · {{ elapsedText }} ago
|
||||
</template>
|
||||
<template v-else>{{ row.value }}</template>
|
||||
</template>
|
||||
</MetadataList>
|
||||
<div v-if="windowProgress != null" class="mt-3">
|
||||
<Progress :model-value="windowProgress" aria-label="Canary window elapsed" />
|
||||
<p class="mt-1 text-caption text-fg-muted">
|
||||
{{ elapsedText }} of 24h elapsed (default window)
|
||||
</p>
|
||||
</div>
|
||||
<p v-else class="mt-3 text-caption text-fg-muted">
|
||||
Install time not recorded, so the window cannot be measured.
|
||||
</p>
|
||||
</template>
|
||||
</template>
|
||||
</Section>
|
||||
</template>
|
||||
@@ -6,6 +6,7 @@ import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table";
|
||||
import CanaryStatusCard from "./CanaryStatusCard.vue";
|
||||
import ServicesCard from "./ServicesCard.vue";
|
||||
import UpdateSettingsCard from "./UpdateSettingsCard.vue";
|
||||
import VersionsCard from "./VersionsCard.vue";
|
||||
@@ -32,6 +33,7 @@ onUnmounted(() => clearInterval(timer));
|
||||
<ServicesCard />
|
||||
<VersionsCard />
|
||||
<UpdateSettingsCard />
|
||||
<CanaryStatusCard />
|
||||
<Section v-if="config?.bootstrap && Object.keys(config.bootstrap).length" title="Startup settings">
|
||||
<Table>
|
||||
<TableBody>
|
||||
|
||||
Reference in new issue
Block a user