Fix: Add agent provisioning progress logging

- Add step-by-step logging to waitForAgentRunning()
- Shows state, installStep, and progress updates
- Logs errors and poll failures for debugging
- Fixes invisible provisioning process issue from Dec 19 split
This commit is contained in:
jester 2025-12-20 17:33:13 +00:00
parent b23d982428
commit 167246dfc6

View File

@ -230,6 +230,7 @@ async function waitForAgentRunning({ ip, timeoutMs = 10 * 60_000 }) {
if (AGENT_TOKEN) headers["Authorization"] = `Bearer ${AGENT_TOKEN}`;
const deadline = Date.now() + timeoutMs;
let lastLoggedStep = null;
while (Date.now() < deadline) {
try {
@ -237,10 +238,32 @@ async function waitForAgentRunning({ ip, timeoutMs = 10 * 60_000 }) {
if (resp.ok) {
const data = await resp.json();
const state = (data.state || "").toLowerCase();
if (state === "running") return data;
if (state === "error") throw new Error(data.error || "agent error");
const step = data.installStep || data.currentStep || "unknown";
const progress = data.progress || "";
// Log state changes and progress
if (step !== lastLoggedStep) {
console.log(`[AGENT ${ip}] state=${state} step=${step} ${progress}`);
lastLoggedStep = step;
}
if (state === "running") {
console.log(`[AGENT ${ip}] ✓ Provisioning complete`);
return data;
}
if (state === "error") {
const errorMsg = data.error || "agent error";
console.error(`[AGENT ${ip}] ✗ ERROR:`, errorMsg);
throw new Error(errorMsg);
}
}
} catch {}
} catch (err) {
// Only log non-connection errors (agent might not be up yet)
if (!err.message.includes("ECONNREFUSED") && !err.message.includes("fetch failed")) {
console.error(`[AGENT ${ip}] Poll error:`, err.message);
}
}
await sleep(3000);
}