Clarify branch follower status timing contexts
This commit is contained in:
@@ -109,7 +109,10 @@ function renderStatusHuman(payload: Record<string, unknown>, _options: ParsedOpt
|
||||
});
|
||||
const next = asOptionalRecord(payload.next);
|
||||
const errors = Array.isArray(payload.errors) ? payload.errors : [];
|
||||
const warnings = Array.isArray(payload.warnings) ? payload.warnings : [];
|
||||
const liveRefreshRows = liveRefreshRowsForPayload(payload);
|
||||
const timingRows = followers.flatMap(timingRowsForFollower).slice(0, 48);
|
||||
const timingContextRows = followers.flatMap(timingContextRowsForFollower).slice(0, 48);
|
||||
const performanceRows = followers.flatMap(performanceRowsForFollower).slice(0, 24);
|
||||
const evidenceRows = followers.flatMap(evidenceRowsForFollower).slice(0, 48);
|
||||
const reconcileRows = followers.flatMap(reconcileRowsForFollower).slice(0, 48);
|
||||
@@ -118,16 +121,19 @@ function renderStatusHuman(payload: Record<string, unknown>, _options: ParsedOpt
|
||||
`CI/CD BRANCH-FOLLOWER STATUS (${payload.ok === false ? "degraded" : "ok"})`,
|
||||
"",
|
||||
table(
|
||||
["CTRL_NS", "ROUTE", "DEPLOY", "READY", "PODS", "STATE_CM", "LEASE"],
|
||||
[[controller?.namespace ?? "-", controller?.route ?? "-", controller?.deploymentName ?? "-", `${controller?.availableReplicas ?? 0}/${controller?.replicas ?? 0}`, controller?.pods ?? "-", controller?.stateConfigMapPresent === true ? "present" : "missing", controller?.leaseHolder ?? "-"]],
|
||||
["CTRL_NS", "ROUTE", "DEPLOY", "READY", "PODS", "PODS_READ", "STATE_CM", "LEASE"],
|
||||
[[controller?.namespace ?? "-", controller?.route ?? "-", controller?.deploymentName ?? "-", `${controller?.availableReplicas ?? 0}/${controller?.replicas ?? 0}`, controller?.pods ?? "-", controller?.podsReadStatus ?? "-", controller?.stateConfigMapPresent === true ? "present" : "missing", controller?.leaseHolder ?? "-"]],
|
||||
),
|
||||
liveRefreshRows.length === 0 ? "" : `\nLIVE REFRESH\n${table(["MODE", "REQUESTED", "EXECUTED", "JOB", "ELAPSED", "IN_TOTAL"], liveRefreshRows)}`,
|
||||
"",
|
||||
table(["FOLLOWER", "PHASE", "ADAPTER", "OBSERVED", "TARGET", "TRIGGERED", "SUCCEEDED", "IN_FLIGHT", "BUDGET", "MESSAGE"], rows),
|
||||
timingRows.length === 0 ? "" : `\nSTAGE TIMINGS\n${table(["FOLLOWER", "STAGE", "STATUS", "SECONDS", "BUDGET", "OBJECT"], timingRows)}`,
|
||||
timingContextRows.length === 0 ? "" : `\nTIMING CONTEXT\n${table(["FOLLOWER", "CONTEXT", "SOURCE", "SECONDS", "STARTED", "FINISHED", "IN_TOTAL"], timingContextRows)}`,
|
||||
performanceRows.length === 0 ? "" : `\nSLOW STAGES\n${table(["FOLLOWER", "STAGE", "STATUS", "SECONDS", "SOURCE", "OBJECT"], performanceRows)}`,
|
||||
evidenceRows.length === 0 ? "" : `\nEVIDENCE\n${table(["FOLLOWER", "TYPE", "STATUS", "DETAIL", "OBJECT"], evidenceRows)}`,
|
||||
reconcileRows.length === 0 ? "" : `\nRECONCILE TIMELINE\n${table(["FOLLOWER", "STEP", "STATUS", "SECONDS", "STARTED", "OBJECT"], reconcileRows)}`,
|
||||
rawStateRows.length === 0 ? "" : `\nRAW STATE DIAGNOSTIC\n${table(["FOLLOWER", "STATE_BYTES", "COMMAND", "TIMELINE", "STEPS", "TIMELINE_BYTES", "REASON"], rawStateRows)}`,
|
||||
warnings.length === 0 ? "" : `\nWARNINGS\n${warnings.map((item) => `- ${item}`).join("\n")}`,
|
||||
errors.length === 0 ? "" : `\nERRORS\n${errors.map((item) => `- ${item}`).join("\n")}`,
|
||||
"",
|
||||
"NEXT",
|
||||
@@ -137,6 +143,19 @@ function renderStatusHuman(payload: Record<string, unknown>, _options: ParsedOpt
|
||||
].filter((line) => line !== "").join("\n");
|
||||
}
|
||||
|
||||
function liveRefreshRowsForPayload(payload: Record<string, unknown>): unknown[][] {
|
||||
const refresh = asOptionalRecord(payload.liveRefresh);
|
||||
if (refresh === null) return [];
|
||||
return [[
|
||||
stringOrNull(refresh.mode) ?? stringOrNull(payload.liveMode) ?? "-",
|
||||
refresh.requested === true ? "yes" : "no",
|
||||
refresh.executed === true ? "yes" : "no",
|
||||
stringOrNull(refresh.name) ?? "-",
|
||||
formatMs(numberOrNull(refresh.elapsedMs)),
|
||||
refresh.includedInStoredTotal === true ? "yes" : "no",
|
||||
]];
|
||||
}
|
||||
|
||||
function renderRunOnceHuman(payload: Record<string, unknown>): string {
|
||||
const followers = arrayRecords(payload.followers);
|
||||
const stateWrites = arrayRecords(payload.stateWrites);
|
||||
@@ -246,6 +265,53 @@ function performanceRowsForFollower(item: Record<string, unknown>): unknown[][]
|
||||
]);
|
||||
}
|
||||
|
||||
function timingContextRowsForFollower(item: Record<string, unknown>): unknown[][] {
|
||||
const context = asOptionalRecord(item.timingContext);
|
||||
if (context === null) return [];
|
||||
const stored = asOptionalRecord(context.storedTiming);
|
||||
const liveRefresh = asOptionalRecord(context.liveRefresh);
|
||||
const nativeGate = asOptionalRecord(context.nativeGateTiming);
|
||||
const rows: unknown[][] = [];
|
||||
if (stored !== null) {
|
||||
rows.push([
|
||||
item.id,
|
||||
"stored",
|
||||
stringOrNull(stored.totalSource) ?? "-",
|
||||
formatSeconds(numberOrNull(stored.totalSeconds)),
|
||||
stringOrNull(stored.startedAt) ?? "-",
|
||||
stringOrNull(stored.finishedAt) ?? "-",
|
||||
"yes",
|
||||
]);
|
||||
}
|
||||
if (liveRefresh !== null) {
|
||||
rows.push([
|
||||
item.id,
|
||||
"live-refresh",
|
||||
stringOrNull(liveRefresh.source) ?? "-",
|
||||
"-",
|
||||
"-",
|
||||
"-",
|
||||
liveRefresh.includedInStoredTotal === true ? "yes" : "no",
|
||||
]);
|
||||
}
|
||||
if (nativeGate !== null) {
|
||||
const detail = [
|
||||
`pipeline=${formatSeconds(numberOrNull(nativeGate.pipelineRunSeconds))}`,
|
||||
`argo=${formatSeconds(numberOrNull(nativeGate.argoOperationSeconds))}`,
|
||||
].join(" ");
|
||||
rows.push([
|
||||
item.id,
|
||||
"native-gates",
|
||||
stringOrNull(nativeGate.source) ?? "-",
|
||||
detail,
|
||||
stringOrNull(nativeGate.argoOperationStartedAt) ?? "-",
|
||||
stringOrNull(nativeGate.argoOperationFinishedAt) ?? "-",
|
||||
nativeGate.argoIncludedInStoredTotal === true ? "argo" : "no",
|
||||
]);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
function reconcileRowsFromRunOnce(payload: Record<string, unknown>, followers: Record<string, unknown>[]): unknown[][] {
|
||||
const timeline = asOptionalRecord(payload.reconcileTimeline);
|
||||
if (timeline !== null) return reconcileRowsForTimeline(timeline, null);
|
||||
@@ -345,6 +411,10 @@ function formatSeconds(value: number | null): string {
|
||||
return value === null ? "-" : `${value}s`;
|
||||
}
|
||||
|
||||
function formatMs(value: number | null): string {
|
||||
return value === null ? "-" : `${Math.round(value / 100) / 10}s`;
|
||||
}
|
||||
|
||||
function boolMatch(value: unknown): string {
|
||||
return value === true ? "match" : value === false ? "mismatch" : "-";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user