fix: bound web-probe and gh diagnostic output (#884)

Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
Lyon
2026-06-25 20:46:41 +08:00
committed by GitHub
parent cdb567aef8
commit 04f8ab2238
4 changed files with 154 additions and 18 deletions
+98 -1
View File
@@ -403,7 +403,9 @@ async function runNodeDelegatedDomain(config: Config, domain: DelegatedNodeDomai
if (domain === "control-plane" && scoped.node !== defaultSpec.nodeId) {
if (scoped.action === "status") {
const result = nodeRuntimeControlPlaneStatus(scoped);
return nodeScopedFullOutput(scoped) ? result : withNodeRuntimeControlPlaneStatusRendered(result, scoped);
if (scoped.originalArgs.includes("--raw")) return result;
if (scoped.originalArgs.includes("--full")) return withNodeRuntimeControlPlaneStatusFullRendered(result, scoped);
return withNodeRuntimeControlPlaneStatusRendered(result, scoped);
}
if (scoped.action === "apply" || scoped.action === "trigger-current" || scoped.action === "refresh" || scoped.action === "sync" || scoped.action === "runtime-migration" || scoped.action === "cleanup-runs") {
if (scoped.confirm && !scoped.dryRun && !scoped.wait) return startNodeDelegatedJob(scoped);
@@ -3197,6 +3199,101 @@ function withNodeRuntimeControlPlaneStatusRendered(result: Record<string, unknow
return { ...result, renderedText, contentType: "text/plain" };
}
function withNodeRuntimeControlPlaneStatusFullRendered(result: Record<string, unknown>, scoped: ReturnType<typeof parseNodeScopedDelegatedOptions>): RenderedCliResult {
const summary = record(result.summary);
const pipelineRun = record(summary.pipelineRun);
const argo = record(summary.argo);
const runtimeSummary = record(summary.runtime);
const publicProbe = record(summary.publicProbe);
const gitMirror = record(summary.gitMirror);
const runtime = record(result.runtime);
const bridge = record(runtime.externalPostgresBridge);
const secrets = record(runtime.externalPostgresSecrets);
const next = record(summary.next);
const workloadReadiness = Array.isArray(runtime.workloadReadiness) ? runtime.workloadReadiness.map(record) : [];
const workloadRows = workloadReadiness.length === 0
? [["-", "-", "-", "-", "-"]]
: workloadReadiness.slice(0, 18).map((item) => [
webObserveText(item.ref),
item.ready === true ? "ok" : "not-ready",
webObserveText(item.readyReplicas),
webObserveText(item.currentReplicas),
webObserveText(item.desiredReplicas),
]);
const bridgeRows = bridge.required === false
? [["not-required", "-", "-", "-", "-"]]
: [[
bridge.ready === true ? "ok" : "failed",
webObserveText(bridge.serviceName),
webObserveText(bridge.endpointAddress),
webObserveText(bridge.port),
`${webObserveText(bridge.expectedEndpointAddress)}:${webObserveText(bridge.expectedPort)}`,
]];
const secretRows = nodeRuntimeExternalPostgresSecretRows(secrets);
const status = result.ok === true ? "ok" : result.ok === false ? "failed" : "-";
const renderedText = [
"hwlab nodes control-plane status --full",
"",
webObserveTable(
["NODE", "LANE", "STATUS", "REASON", "SOURCE", "PIPELINERUN"],
[[
scoped.node,
scoped.lane,
status,
webObserveShort(webObserveText(summary.degradedReason ?? result.degradedReason), 40),
shortValue(summary.sourceCommit ?? result.sourceCommit),
webObserveShort(webObserveText(pipelineRun.name ?? result.pipelineRun), 36),
]],
),
"",
webObserveTable(
["STAGE", "STATUS", "DETAIL"],
[
["pipeline", pipelineRun.ready === true ? "ok" : pipelineRun.exists === true ? webObserveText(pipelineRun.status) : "missing", webObserveShort(webObserveText(pipelineRun.reason ?? pipelineRun.message), 80)],
["argo", argo.ready === true ? "ok" : "failed", `${webObserveText(argo.syncStatus)}/${webObserveText(argo.health)} rev=${shortValue(argo.syncRevision)}`],
["runtime", runtimeSummary.ready === true ? "ok" : "failed", `namespace=${webObserveText(runtimeSummary.namespace)} workloads=${webObserveText(runtimeSummary.workloadReady)} pg=${webObserveText(runtimeSummary.externalPostgresReady ?? runtimeSummary.localPostgresReady)}`],
["public", publicProbe.ready === true ? "ok" : "failed", webObserveShort(webObserveText(record(publicProbe.diagnostic).kind ?? record(publicProbe.diagnostic).message), 80)],
["git-mirror", gitMirror.ready === true ? "ok" : "failed", `pending=${webObserveText(gitMirror.pendingFlush)} inSync=${webObserveText(gitMirror.githubInSync)}`],
],
),
"",
"RUNTIME_WORKLOADS",
webObserveTable(["REF", "READY", "READY_REPLICAS", "CURRENT", "DESIRED"], workloadRows),
...(workloadReadiness.length > workloadRows.length ? [` ... ${workloadReadiness.length - workloadRows.length} more workloads omitted; use --raw for complete JSON.`] : []),
"",
"EXTERNAL_POSTGRES_BRIDGE",
webObserveTable(["STATUS", "SERVICE", "ENDPOINT", "PORT", "EXPECTED"], bridgeRows),
"",
"EXTERNAL_POSTGRES_SECRETS",
webObserveTable(["ROLE", "SECRET", "KEY", "PRESENT", "VALUES_PRINTED"], secretRows),
"",
"NEXT",
` ${summary.nextAction ?? next.full ?? `bun scripts/cli.ts hwlab nodes control-plane status --node ${scoped.node} --lane ${scoped.lane} --full`}`,
` bun scripts/cli.ts hwlab nodes control-plane status --node ${scoped.node} --lane ${scoped.lane} --raw`,
"",
"Disclosure:",
" --full status is a bounded runtime-workloads drill-down view; use --raw only when complete JSON is required.",
" Secret evidence is limited to object metadata, key names, presence, and valuesPrinted=false.",
].join("\n");
return { ...result, renderedText, contentType: "text/plain" };
}
function nodeRuntimeExternalPostgresSecretRows(secrets: Record<string, unknown>): unknown[][] {
if (secrets.required === false) return [["not-required", "-", "-", "-", "false"]];
if (secrets.required === true && secrets.ready !== true && secrets.degradedReason !== undefined) {
return [[webObserveText(secrets.degradedReason), "-", "-", "false", "false"]];
}
const cloudApi = record(secrets.cloudApi);
const openfga = record(secrets.openfga);
const datastoreUri = record(openfga.datastoreUri);
const authnPresharedKey = record(openfga.authnPresharedKey);
return [
["cloudApi", webObserveText(cloudApi.secret), webObserveText(cloudApi.key), webObserveText(cloudApi.present), webObserveText(cloudApi.valuesPrinted ?? false)],
["openfga.datastoreUri", webObserveText(datastoreUri.secret), webObserveText(datastoreUri.key), webObserveText(datastoreUri.present), webObserveText(datastoreUri.valuesPrinted ?? false)],
["openfga.authnPresharedKey", webObserveText(authnPresharedKey.secret), webObserveText(authnPresharedKey.key), webObserveText(authnPresharedKey.present), webObserveText(authnPresharedKey.valuesPrinted ?? false)],
];
}
function nodeRuntimeGitMirrorStatus(scoped: ReturnType<typeof parseNodeScopedDelegatedOptions>): Record<string, unknown> {
const spec = scoped.spec;
const mirror = nodeRuntimeGitMirrorTarget(spec);