fix: reprovision workflow bugs — SSH host key warnings, log following, status priority
Some checks failed
CI/CD / lint (pull_request) Failing after 10s
CI/CD / test (pull_request) Failing after 10s
CI/CD / typecheck (pull_request) Failing after 23s
CI/CD / build (pull_request) Has been skipped
CI/CD / publish-rpm (pull_request) Has been skipped
CI/CD / publish-deb (pull_request) Has been skipped

- Add UserKnownHostsFile=/dev/null to SSH in debug and reprovision commands
- Track install state in log follower so it doesn't exit prematurely on "installed"
- Reorder bastion status check to prioritize active queue over stale installed state
- Update .gitignore with task file entries

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Michal
2026-03-30 22:59:45 +01:00
parent 63cc033e3e
commit 6a5f23c0f5
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` });
}); });
} }