Skip to content

Commit 63a55be

Browse files
authored
test: reboot Kairos node in e2e (#816)
## Summary - reboot the installed Kairos node after its initial cloud-config boot - wait for SSH to return from a different kernel boot ID - bound SSH probes with server keepalives so shutdown connections cannot hang the test - run the existing system, SSH, active-boot, and K3s checks after the reboot ## Why The E2E previously validated only the first installed boot, while Kairos was applying cloud config. That could miss failures that appear on a normal immutable boot. Rebooting before the substantive guest checks verifies that SSH and the rest of the configured system survive independently of first-boot initialization. Closes #815. ## Validation - `just check-format` - `shellcheck images/kairos-fedora/e2e.sh` - `bash -n images/kairos-fedora/e2e.sh` - `just e2e-kairos-fedora` (full install, reboot, second-boot SSH, and guest checks passed)
1 parent 0f4ff68 commit 63a55be

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

images/kairos-fedora/e2e.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ ssh_cmd() {
297297
-o BatchMode=yes \
298298
-o ConnectTimeout=5 \
299299
-o LogLevel=ERROR \
300+
-o ServerAliveCountMax=1 \
301+
-o ServerAliveInterval=5 \
300302
-o StrictHostKeyChecking=no \
301303
-o UserKnownHostsFile=/dev/null \
302304
"kairos@127.0.0.1" \
@@ -327,6 +329,35 @@ wait_for_ssh() {
327329
die "SSH did not become reachable before ${E2E_BOOT_TIMEOUT}"
328330
}
329331

332+
reboot_and_wait_for_ssh() {
333+
local boot_id
334+
local deadline
335+
local timeout_seconds
336+
337+
boot_id="$(ssh_cmd 'cat /proc/sys/kernel/random/boot_id')"
338+
log "Rebooting installed system to validate SSH on an immutable boot"
339+
ssh_cmd 'sudo -n systemctl reboot' >/dev/null 2>&1 || true
340+
ssh_ready=0
341+
342+
timeout_seconds="$(duration_to_seconds "$E2E_BOOT_TIMEOUT")"
343+
deadline=$((SECONDS + timeout_seconds))
344+
345+
while ((SECONDS < deadline)); do
346+
if [[ -n "$qemu_pid" ]] && ! kill -0 "$qemu_pid" >/dev/null 2>&1; then
347+
wait "$qemu_pid" || true
348+
die "QEMU validation VM exited while rebooting"
349+
fi
350+
351+
if ssh_cmd "test \"\$(cat /proc/sys/kernel/random/boot_id)\" != '${boot_id}'" >"${logs_dir}/ssh-reboot-wait-last.log" 2>&1; then
352+
ssh_ready=1
353+
return
354+
fi
355+
sleep 5
356+
done
357+
358+
die "SSH did not become reachable after reboot before ${E2E_BOOT_TIMEOUT}"
359+
}
360+
330361
collect_ssh_diagnostics() {
331362
[[ "$ssh_ready" == 1 ]] || return 0
332363

@@ -432,6 +463,7 @@ main() {
432463
phase="validate"
433464
start_qemu validate "" "$ovmf_code" "$ovmf_vars"
434465
wait_for_ssh
466+
reboot_and_wait_for_ssh
435467
run_guest_checks
436468

437469
phase="complete"

0 commit comments

Comments
 (0)