8000 fix(minvmd): reap a stale gvproxy before drawing the node proxy port by gominimal-aw-bot[bot] · Pull Request #2313 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(minvmd): reap a stale gvproxy before drawing the node proxy port - #2313

Merged
norrietaylor merged 4 commits into
mainfrom
inbox-patch/fix-gvproxy-reap-before-port-draw-561be2a63c07664b
Oct 19, 2026
Merged

norrietaylor merged 4 commits into
mainfrom
inbox-patch/fix-gvproxy-reap-before-port-draw-561be2a63c07664b

Conversation

@gominimal-aw-bot
@gominimal-aw-bot gominimal-aw-bot Bot commented Oct 18, 2026 •
Copy link
Copy Markdown
Contributor

Routing-Key: inbox-route/I_kwDOSUhdos8AAAABX3vbpw

A killed supervisor (SIGKILL, abort) leaves its gvproxy alive, and the leftover keeps the hostname proxy's default port bound. The supervisor drew the node proxy port before it reaped the stale gvproxy, so the draw saw the default port refused and handed the proxy an ephemeral port for no reason; the reap that freed the default ran only later, at the gvproxy spawn. After a kill-based restart the hostname proxy never returned to its default port.

The fix reaps a stale gvproxy before the port draw. The reaper's guard still fails the start when the matching gvproxy belongs to a live minvmd, and the resolved gvproxy binary and switch socket are handed to the spawn block, which matches on the returned switch socket, so the "is gvproxy installed" decision is made once.

The "assigned the node port" log line now also names the pid and executable holding a preferred port that was skipped for bind refusal. This is intended: it tells the reader which leftover owns the bind the boot moved off. On macOS the lookup runs lsof, but only on that bind-refused path (informed by the minvmd gvproxy pidfd spec).

A unit test holds the preferred port, checks the draw skips it with bind refused, releases it, and checks the same draw hands it back. It covers the draw's behaviour only. The order of reap and draw in run_foreground needs a real VM, so only the e2e lanes check it.

Verification

  • just fix, just clippy (macOS scope) — pass
  • just test (macOS scope: minvmd + sessions) — 1234 passed
  • cmd::run::tests::node_port_draw_skips_a_held_preferred_port_and_hands_it_back_once_released — pass

A SIGKILLed or aborted supervisor leaves its gvproxy alive, and the
leftover keeps the hostname proxy's default port (7654) bound. The
supervisor drew the node proxy port before it reaped the stale
gvproxy, so the draw saw the default refused and handed the proxy an
ephemeral port for no reason; the reap that freed the default ran
only later, at the gvproxy spawn.

Reap before the draw. The reaper's own guard still fails the start
when the matching gvproxy belongs to a live minvmd, and the resolved
binary and switch socket are handed to the spawn block so nothing
resolves twice.

The "assigned the node port" log line now also names the holder of a
preferred port skipped for bind refusal, so the supervisor's log says
which leftover owned the bind the boot moved off.

A run.rs unit test holds the preferred port, draws it away, releases
it (the reap's effect), and draws it back.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gominimal-aw-bot
gominimal-aw-bot Bot requested a review from a team as a code owner October 18, 2026 03:13
@gominimal-aw-bot gominimal-aw-bot Bot added the agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it. label Oct 18, 2026
@coderabbitai
coderabbitai Bot commented Oct 18, 2026 •
Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 1 billable file and costs up to $0.25.

Or wait 56 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 1c5a8b71-35ba-4ab8-908d-28b42e77c62f
📥 Commits

Reviewing files that changed from the base of the PR and between 11b0b44 and 4572aff.

📒 Files selected for processing: 1
  • crates/minvmd/src/cmd/run.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@gominimal-aw-bot gominimal-aw-bot Bot added the agent:resolve Consent gate: pr-conflict-resolver may rewrite this branch label Oct 18, 2026
@norrietaylor norrietaylor changed the title fix: fix(minvmd): reap a stale gvproxy before drawing the node proxy port fix(minvmd): reap a stale gvproxy before drawing the node proxy port Oct 18, 2026
…ignature

PathBuf is imported only inside run_foreground, so the module-level
helper failed to compile wherever the minvmd_libkrun cfg is set.
The spawn block matches on the switch socket the pre-draw reaper
returns instead of calling binary.exists() a second time, so the two
checks can no longer disagree.

The node-port draw test is renamed: it pins that a held preferred port
is skipped and handed back once released, not the reap-before-draw
order, which only the e2e lanes check.
@norrietaylor
Copy link
Copy Markdown
Member

/review

@minimal-foundry
minimal-foundry Bot commented Oct 18, 2026 •
Copy link
Copy Markdown
Contributor

Approved: no findings at 4572aff79558.

Nothing to do.

Clobber: none in this remit: git diff base..head --stat shows only run.rs. Correctness (supply-chain) the changed code calls only pre-existing minvmd functions — resolve_gvproxy_path, resolve_switch_sock, reap_stale_gvproxy, prepare_socket_dir, remove_stale_socket, port_holder — all unchanged in behavior; the PR merely reorders the reap relative to the node-proxy-port draw and reuses t…

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Panel: 2 of 3 personas ran (correctness, security); did not complete: supply-chain.

Comment thread crates/minvmd/src/cmd/run.rs Resolved
port_holder already formats its holder as `pid <pid> (<exe>)`, so wrapping it again
logged `pid 1234 (pid 1234 (gvproxy))`. Use the holder as configured_node_port does.
@norrietaylor
Copy link
Copy Markdown
Member

/review

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE withheld: 1 unresolved thread — minimal-foundry[bot] crates/minvmd/src/cmd/run.rs.

minimal-review — advisory review

Verdict COMMENT — No findings.

Panel: 1 of 3 personas ran (supply-chain); did not complete: correctness, security.

@minimal-foundry minimal-foundry Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approved

Verdict APPROVE — every review thread is resolved; @norrietaylor closed the last one. The review of 4572aff79558 withheld this approval on the threads open then. Posted as a comment, as the review itself was; the check and the label carry it.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Oct 18, 2026
@norrietaylor
Copy link
Copy Markdown
Member

/review

1 similar comment
@norrietaylor
Copy link
Copy Markdown
Member

/review

@norrietaylor norrietaylor left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on ARCH PASS at 4572aff.

@bryan-minimal bryan-minimal left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read against the branch: the reap now runs after the alive lock is taken (phase 1 of run_foreground) and before the port draw, so the reaper's live-minvmd guard still holds, and the spawn block takes the resolved pair instead of resolving again. The three match arms keep their old meaning (own-IP without gvproxy still fails loudly). The holder lookup only runs on the bind-refused skip, so lsof on macOS stays off the normal path. The unit test pins the draw half; the reap-before-draw order needs the e2e lane, which passed.

@norrietaylor
norrietaylor added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit 7675e02 Oct 19, 2026
37 checks passed
@norrietaylor
norrietaylor deleted the inbox-patch/fix-gvproxy-reap-before-port-draw-561be2a63c07664b branch October 19, 2026 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it. agent:resolve Consent gate: pr-conflict-resolver may rewrite this branch review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0