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:
parent
b23d982428
commit
167246dfc6
@ -230,6 +230,7 @@ async function waitForAgentRunning({ ip, timeoutMs = 10 * 60_000 }) {
|
|||||||
if (AGENT_TOKEN) headers["Authorization"] = `Bearer ${AGENT_TOKEN}`;
|
if (AGENT_TOKEN) headers["Authorization"] = `Bearer ${AGENT_TOKEN}`;
|
||||||
|
|
||||||
const deadline = Date.now() + timeoutMs;
|
const deadline = Date.now() + timeoutMs;
|
||||||
|
let lastLoggedStep = null;
|
||||||
|
|
||||||
while (Date.now() < deadline) {
|
while (Date.now() < deadline) {
|
||||||
try {
|
try {
|
||||||
@ -237,10 +238,32 @@ async function waitForAgentRunning({ ip, timeoutMs = 10 * 60_000 }) {
|
|||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
const state = (data.state || "").toLowerCase();
|
const state = (data.state || "").toLowerCase();
|
||||||
if (state === "running") return data;
|
const step = data.installStep || data.currentStep || "unknown";
|
||||||
if (state === "error") throw new Error(data.error || "agent error");
|
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 (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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch {}
|
|
||||||
await sleep(3000);
|
await sleep(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user