fix: reprovision workflow bugs #7

Merged
michal merged 1 commits from fix/reprovision-bugs into main 2026-03-30 22:44:44 +00:00
5 changed files with 26 additions and 13 deletions

4
.gitignore vendored
View File

@@ -23,3 +23,7 @@ node_modules/
# OS specific # OS specific
.DS_Store .DS_Store
# Task files
# tasks.json
# tasks/

View File

@@ -103,6 +103,7 @@ export function registerDebugCommand(parent: Command): void {
const sshArgs = [ const sshArgs = [
"-o", "StrictHostKeyChecking=no", "-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "ConnectTimeout=10", "-o", "ConnectTimeout=10",
...(sshKey !== undefined ? ["-i", sshKey] : []), ...(sshKey !== undefined ? ["-i", sshKey] : []),
`${effectiveUser}@${ip}`, `${effectiveUser}@${ip}`,

View File

@@ -103,6 +103,7 @@ async function followLogs(
let lastStageCount = 0; let lastStageCount = 0;
let lastStatus = ""; let lastStatus = "";
let sawInstalling = false;
while (true) { while (true) {
try { try {
@@ -118,6 +119,10 @@ async function followLogs(
lastStatus = status; lastStatus = status;
} }
if (status === "installing" || status === "queued") {
sawInstalling = true;
}
// Print new stages // Print new stages
if (log && log.length > lastStageCount) { if (log && log.length > lastStageCount) {
for (let i = lastStageCount; i < log.length; i++) { for (let i = lastStageCount; i < log.length; i++) {
@@ -130,8 +135,9 @@ async function followLogs(
lastStageCount = log.length; lastStageCount = log.length;
} }
// Done // Only exit on "installed" if we actually saw the install happen
if (status === "installed") { // (avoids exiting immediately when following a reprovision that hasn't started yet)
if (status === "installed" && sawInstalling) {
const ip = data["ip"] ?? ""; const ip = data["ip"] ?? "";
console.log(""); console.log("");
console.log(` ${GREEN}${BOLD}Install complete!${RESET}${ip ? ` ${DIM}ssh lab@${ip}${RESET}` : ""}`); console.log(` ${GREEN}${BOLD}Install complete!${RESET}${ip ? ` ${DIM}ssh lab@${ip}${RESET}` : ""}`);

View File

@@ -144,6 +144,7 @@ export function registerReprovisionCommand(parent: Command): void {
const sshArgs = [ const sshArgs = [
"-o", "StrictHostKeyChecking=no", "-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "ConnectTimeout=10", "-o", "ConnectTimeout=10",
...(sshKey !== undefined ? ["-i", sshKey] : []), ...(sshKey !== undefined ? ["-i", sshKey] : []),
`${effectiveUser}@${ip}`, `${effectiveUser}@${ip}`,

View File

@@ -257,17 +257,7 @@ export function registerBastionRoutes(app: FastifyInstance, db: DbClient): void
const queued = bastion.state.install_queue[mac]; const queued = bastion.state.install_queue[mac];
const installed = bastion.state.installed[mac]; const installed = bastion.state.installed[mac];
if (installed) { // Active install takes priority over old installed state (reprovision case)
return {
mac,
hostname: installed.hostname,
status: "installed",
role: installed.role,
ip: installed.ip,
installed_at: installed.installed_at,
};
}
if (queued) { if (queued) {
return { return {
mac, mac,
@@ -282,6 +272,17 @@ export function registerBastionRoutes(app: FastifyInstance, db: DbClient): void
}; };
} }
if (installed) {
return {
mac,
hostname: installed.hostname,
status: "installed",
role: installed.role,
ip: installed.ip,
installed_at: installed.installed_at,
};
}
return reply.code(404).send({ error: `MAC ${mac} not found in install queue or installed` }); return reply.code(404).send({ error: `MAC ${mac} not found in install queue or installed` });
}); });
} }