diff --git a/.gitignore b/.gitignore index f270674..9dc1e1c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,7 @@ node_modules/ # OS specific .DS_Store + +# Task files +# tasks.json +# tasks/ diff --git a/bastion/src/cli/src/commands/debug.ts b/bastion/src/cli/src/commands/debug.ts index 2bb4f24..903ca8a 100644 --- a/bastion/src/cli/src/commands/debug.ts +++ b/bastion/src/cli/src/commands/debug.ts @@ -103,6 +103,7 @@ export function registerDebugCommand(parent: Command): void { const sshArgs = [ "-o", "StrictHostKeyChecking=no", + "-o", "UserKnownHostsFile=/dev/null", "-o", "ConnectTimeout=10", ...(sshKey !== undefined ? ["-i", sshKey] : []), `${effectiveUser}@${ip}`, diff --git a/bastion/src/cli/src/commands/logs.ts b/bastion/src/cli/src/commands/logs.ts index 48630a6..3ab8487 100644 --- a/bastion/src/cli/src/commands/logs.ts +++ b/bastion/src/cli/src/commands/logs.ts @@ -103,6 +103,7 @@ async function followLogs( let lastStageCount = 0; let lastStatus = ""; + let sawInstalling = false; while (true) { try { @@ -118,6 +119,10 @@ async function followLogs( lastStatus = status; } + if (status === "installing" || status === "queued") { + sawInstalling = true; + } + // Print new stages if (log && log.length > lastStageCount) { for (let i = lastStageCount; i < log.length; i++) { @@ -130,8 +135,9 @@ async function followLogs( lastStageCount = log.length; } - // Done - if (status === "installed") { + // Only exit on "installed" if we actually saw the install happen + // (avoids exiting immediately when following a reprovision that hasn't started yet) + if (status === "installed" && sawInstalling) { const ip = data["ip"] ?? ""; console.log(""); console.log(` ${GREEN}${BOLD}Install complete!${RESET}${ip ? ` ${DIM}ssh lab@${ip}${RESET}` : ""}`); diff --git a/bastion/src/cli/src/commands/reprovision.ts b/bastion/src/cli/src/commands/reprovision.ts index 7e421fc..9f213f6 100644 --- a/bastion/src/cli/src/commands/reprovision.ts +++ b/bastion/src/cli/src/commands/reprovision.ts @@ -144,6 +144,7 @@ export function registerReprovisionCommand(parent: Command): void { const sshArgs = [ "-o", "StrictHostKeyChecking=no", + "-o", "UserKnownHostsFile=/dev/null", "-o", "ConnectTimeout=10", ...(sshKey !== undefined ? ["-i", sshKey] : []), `${effectiveUser}@${ip}`, diff --git a/bastion/src/labd/src/routes/bastions.ts b/bastion/src/labd/src/routes/bastions.ts index 9c8e181..12267f9 100644 --- a/bastion/src/labd/src/routes/bastions.ts +++ b/bastion/src/labd/src/routes/bastions.ts @@ -257,17 +257,7 @@ export function registerBastionRoutes(app: FastifyInstance, db: DbClient): void const queued = bastion.state.install_queue[mac]; const installed = bastion.state.installed[mac]; - if (installed) { - return { - mac, - hostname: installed.hostname, - status: "installed", - role: installed.role, - ip: installed.ip, - installed_at: installed.installed_at, - }; - } - + // Active install takes priority over old installed state (reprovision case) if (queued) { return { 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` }); }); }