fix: render web probe observe start summary (#659)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -7204,7 +7204,7 @@ function runNodeWebProbeObserveStart(
|
|||||||
secretSpec: RuntimeSecretSpec,
|
secretSpec: RuntimeSecretSpec,
|
||||||
material: BootstrapAdminPasswordMaterial,
|
material: BootstrapAdminPasswordMaterial,
|
||||||
credential: Record<string, unknown>,
|
credential: Record<string, unknown>,
|
||||||
): Record<string, unknown> {
|
): Record<string, unknown> | RenderedCliResult {
|
||||||
const jobId = `webobs-${Date.now().toString(36)}-${randomBytes(3).toString("hex")}`;
|
const jobId = `webobs-${Date.now().toString(36)}-${randomBytes(3).toString("hex")}`;
|
||||||
const timestamp = new Date().toISOString().replace(/[-:]/gu, "").replace(/[.]\d{3}Z$/u, "Z");
|
const timestamp = new Date().toISOString().replace(/[-:]/gu, "").replace(/[.]\d{3}Z$/u, "Z");
|
||||||
const day = timestamp.slice(0, 8);
|
const day = timestamp.slice(0, 8);
|
||||||
@@ -7256,7 +7256,7 @@ function runNodeWebProbeObserveStart(
|
|||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
})
|
})
|
||||||
: null;
|
: null;
|
||||||
return {
|
return renderWebObserveStartResult({
|
||||||
ok: result.exitCode === 0 && started?.ok === true,
|
ok: result.exitCode === 0 && started?.ok === true,
|
||||||
status: result.exitCode === 0 && started?.ok === true ? "started" : "blocked",
|
status: result.exitCode === 0 && started?.ok === true ? "started" : "blocked",
|
||||||
command: `hwlab nodes web-probe observe start --node ${options.node} --lane ${options.lane}`,
|
command: `hwlab nodes web-probe observe start --node ${options.node} --lane ${options.lane}`,
|
||||||
@@ -7273,7 +7273,7 @@ function runNodeWebProbeObserveStart(
|
|||||||
next: webObserveNextCommands(observerId),
|
next: webObserveNextCommands(observerId),
|
||||||
result: compactCommandResultRedacted(result, [material.password ?? ""]),
|
result: compactCommandResultRedacted(result, [material.password ?? ""]),
|
||||||
valuesRedacted: true,
|
valuesRedacted: true,
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function runNodeWebProbeObserveStatus(options: NodeWebProbeObserveOptions, spec: HwlabRuntimeLaneSpec): Record<string, unknown> | RenderedCliResult {
|
function runNodeWebProbeObserveStatus(options: NodeWebProbeObserveOptions, spec: HwlabRuntimeLaneSpec): Record<string, unknown> | RenderedCliResult {
|
||||||
@@ -8447,6 +8447,66 @@ function withWebObserveRendered(result: Record<string, unknown>, renderedText: s
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderWebObserveStartResult(result: Record<string, unknown>): Record<string, unknown> {
|
||||||
|
const observer = record(result.observer);
|
||||||
|
const heartbeat = record(observer.heartbeat);
|
||||||
|
const manifest = record(observer.manifest);
|
||||||
|
const commandResult = record(result.result);
|
||||||
|
const credential = record(result.credential);
|
||||||
|
const id = result.id ?? observer.id ?? observer.jobId ?? manifest.jobId ?? "-";
|
||||||
|
const status = result.status ?? manifest.status ?? heartbeat.status ?? "-";
|
||||||
|
const stateDir = observer.stateDir ?? manifest.stateDir ?? "-";
|
||||||
|
const blockedRows = result.ok === true ? [] : [
|
||||||
|
"",
|
||||||
|
"Blocked detail:",
|
||||||
|
webObserveTable(
|
||||||
|
["EXIT", "TIMEOUT", "STDOUT", "STDERR"],
|
||||||
|
[[
|
||||||
|
webObserveText(commandResult.exitCode),
|
||||||
|
webObserveText(commandResult.timedOut),
|
||||||
|
webObserveShort(webObserveText(commandResult.stdoutTail ?? commandResult.stdout), 160),
|
||||||
|
webObserveShort(webObserveText(commandResult.stderrTail ?? commandResult.stderr), 300),
|
||||||
|
]],
|
||||||
|
),
|
||||||
|
];
|
||||||
|
const renderedText = [
|
||||||
|
webObserveTable(
|
||||||
|
["OBSERVER", "NODE", "LANE", "STATUS", "PID", "SAMPLE", "UPDATED"],
|
||||||
|
[[
|
||||||
|
id,
|
||||||
|
result.node,
|
||||||
|
result.lane,
|
||||||
|
status,
|
||||||
|
observer.pid ?? heartbeat.pid,
|
||||||
|
heartbeat.sampleSeq,
|
||||||
|
heartbeat.updatedAt,
|
||||||
|
]],
|
||||||
|
),
|
||||||
|
"",
|
||||||
|
webObserveTable(
|
||||||
|
["URL", "TARGET_PATH", "STATE_DIR"],
|
||||||
|
[[result.url, result.targetPath, webObserveShort(webObserveText(stateDir), 96)]],
|
||||||
|
),
|
||||||
|
"",
|
||||||
|
webObserveTable(
|
||||||
|
["CREDENTIAL", "SOURCE", "VALUES"],
|
||||||
|
[[
|
||||||
|
credential.username ?? "-",
|
||||||
|
credential.sourceRef ?? "-",
|
||||||
|
credential.valuesRedacted === true ? "redacted" : "unknown",
|
||||||
|
]],
|
||||||
|
),
|
||||||
|
...blockedRows,
|
||||||
|
"",
|
||||||
|
"NEXT",
|
||||||
|
` status: bun scripts/cli.ts hwlab nodes web-probe observe status ${id}`,
|
||||||
|
` analyze: bun scripts/cli.ts hwlab nodes web-probe observe analyze ${id}`,
|
||||||
|
` command: bun scripts/cli.ts hwlab nodes web-probe observe command ${id} --type mark --label checkpoint`,
|
||||||
|
` stop: bun scripts/cli.ts hwlab nodes web-probe observe stop ${id}`,
|
||||||
|
].join("\n");
|
||||||
|
return withWebObserveRendered(result, renderedText);
|
||||||
|
}
|
||||||
|
|
||||||
function renderWebObserveStatusResult(result: Record<string, unknown>): Record<string, unknown> {
|
function renderWebObserveStatusResult(result: Record<string, unknown>): Record<string, unknown> {
|
||||||
const observer = record(result.observer);
|
const observer = record(result.observer);
|
||||||
const commandResult = record(result.result);
|
const commandResult = record(result.result);
|
||||||
|
|||||||
Reference in New Issue
Block a user