fix capture path: guard against set -u + preserve cmd_capture's empty-host ISO
Some checks failed
DB migration compat / Check if migrations changed (push) Has been cancelled
DB migration compat / Back-compat — Current branch migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migration compat / Forward-compat — Current branch code with ${{ needs.check-migrations-changed.outputs.base_branch }} branch migrations (push) Has been cancelled
DB migration compat / No migration changes (skipped) (push) Has been cancelled

Two bugs surfaced by end-to-end testing against a freshly-built qcow2:

1. $STACK_EMULATOR_CLI_WROTE_ISO was referenced unguarded under `set -u`,
   so any code path that didn't set it (capture, direct-shell) tripped
   `unbound variable` before reaching the early-return. Use :- default.

2. ensure_runtime_config_iso was overwriting cmd_capture's specialized
   empty-VM_DIR_HOST ISO with the host-dir variant. Since virtfs is
   detached in capture mode, run-stack-container then tried to publish
   internal-pck to /host/... and restart-looped stack.service, so no
   service ever became healthy and capture aborted after 240s. Previously
   masked by snapshot_fallback_to_cold_boot; 510ef3801 fixed the fallback
   mask and exposed this. Skip regen when EMULATOR_CAPTURING_SNAPSHOT=1.
This commit is contained in:
Bilal Godil 2026-04-16 15:30:46 -07:00
parent 39b5c083e7
commit 7acb3ed20b

View File

@ -174,7 +174,15 @@ ensure_runtime_config_iso() {
# otherwise we'd fall through to make_iso_from_dir and require
# hdiutil/mkisofs/genisoimage, which is exactly the host dep the CLI path
# is designed to remove.
if [ "$STACK_EMULATOR_CLI_WROTE_ISO" = "1" ] && [ -s "$(runtime_iso_path)" ]; then
if [ "${STACK_EMULATOR_CLI_WROTE_ISO:-}" = "1" ] && [ -s "$(runtime_iso_path)" ]; then
return 0
fi
# In capture mode, cmd_capture already wrote a specialized ISO with an
# empty STACK_EMULATOR_VM_DIR_HOST — required because virtfs is detached
# for snapshot compatibility, and run-stack-container would otherwise
# try to publish internal-pck to /host/... and restart-loop
# stack.service. Trust that write and don't overwrite it.
if [ "${EMULATOR_CAPTURING_SNAPSHOT:-}" = "1" ] && [ -s "$(runtime_iso_path)" ]; then
return 0
fi
# Direct-shell invocation path: regenerate unconditionally. Port env vars