Repository navigation
feat(fire_vmm): let exec wait for a booting VM's agent - #200
Open
markovejnovic wants to merge 1 commit into
Open
markovejnovic wants to merge 1 commit into
markovejnovic wants to merge 1 commit into
Conversation
An exec on a VM whose guest agent is not listening yet answers :agent_unavailable at once, so a caller that boots a VM and runs something in it has to poll. usher polls every 250 ms, and in production that poll is most of a login: the agent comes up a few hundred milliseconds into boot, each refused exec costs under a millisecond, and the sleeps between them cost up to 250 ms. Nothing tells the host when the agent starts listening, but firecracker refuses a CONNECT to a guest port nothing listens on at once, so probing is cheap: a Unix-socket connect and one line. exec takes :wait_for_agent (ms), and probes the VM's vsock every 2 ms until the agent answers or the wait runs out, then runs as before, with :timeout starting once the agent answers. Without the option exec is unchanged. The wait is its own span, Hyper.Node.FireVMM.Agent.wait_for_agent, so a trace shows how long each VM took to bring its agent up.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: an
execon a VM whose guest agent isn't listening yet answers:agent_unavailableat once, so a caller that boots a VM and runs something in it has to poll. usher (hypervm.sh) polls every 250 ms. With #199's spans, a production login reads:create_vmexecsexecThe agent came up somewhere between 300 and 550 ms into boot, but the poll quantised it to 250 ms steps.
What:
exectakes:wait_for_agent(ms). With it, an exec on a VM still booting probes the VM's vsock every 2 ms until the agent answers or the wait runs out, then runs as before.:timeoutstarts once the agent answers, so the command keeps its own deadline. Without the optionexecis unchanged.The probe is
Relay.agent_listening?/2: the relay's ownRelayDialerhandshake, closed once firecracker answersOK. While nothing in the guest listens on 1024, firecracker refuses theCONNECTat once, so a probe costs a Unix-socket connect and one line. The 2 ms interval bounds what the wait adds after the agent comes up.The wait gets its own span,
Hyper.Node.FireVMM.Agent.wait_for_agent(vm_id,wait_ms), so a trace shows how long each VM took to bring its agent up.Why poll and not a push from the guest: the guest agent is baked into each image when it's loaded (
OciLoader), so a guest-initiated "I'm up" over vsock would only reach images loaded after it ships. It would also need a host listener on every VM (today the guest-services one, on port 1100, runs only for VMs that have services), plus a fallback for old agents. Probing works for every existing image and lands within 2 ms of the agent coming up.Tests:
agent_wait_test.exsruns a realRelayagainst a fake firecracker that refuses everyCONNECTuntil the guest "boots"::agent_unavailableafter about that long, not a hang.Each test fails when the code is broken: dropping the wait fails the first and third tests, and a 250 ms probe interval fails the first one's bound.
Checked locally:
compile --warnings-as-errorsin dev and test,credo --strict, and the agent, relay and Hyper suites (59 tests and properties).mix check, which can't run on a Mac (the suidhelper stamp compiler). CI is the gate for those.