Repository navigation
Fix: clean up dnsmasq DHCP leases when destroying a ch VM - #1104
Merged
Merged
Conversation
DnsmasqDHCPManager.RemoveReservation only removed a VM's --dhcp-hostsfile reservation on destroy, never its corresponding lease-file entry. dnsmasq treats the lease file as its own in-memory-backed state (read once at startup, then owned/rewritten by the running process) β SIGHUP reloads the hosts file but never forgets an already-granted lease. Since chIPs allocates low addresses first, the very next ch VM to reuse a freshly freed IP would have its real DHCP handshake silently redirected elsewhere, while onctl still believed it got the reserved address β create would then hang until its SSH-wait timeout. RemoveReservation now also strips the MAC's lease-file entry and restarts dnsmasq (the only way to force it to forget an in-memory lease without adding a new dhcp_release/dnsmasq-utils host dependency), using a newly persisted per-bridge cidr file so the restart doesn't need cidr threaded through the DHCPManager interface. Reproduced and verified live on a real cloud-hypervisor/dnsmasq/Windows-guest chain: three consecutive create/destroy/create cycles on the same freed IP, all completing in ~20s with no SSH-wait timeouts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iVNj3mykz8m7QfuxWN3ae
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.
Summary
DnsmasqDHCPManager.RemoveReservationremoved a destroyed VM's DHCP hosts-file reservation but never its dnsmasq lease-file entry, since SIGHUP reloads the hosts file but never makes dnsmasq forget an already-granted lease.chIPsallocates low addresses first, the very nextchVM to reuse a freed IP would get silently redirected to a different address by DHCP while onctl still believed it held the reserved one βcreatewould hang until its SSH-wait timeout.RemoveReservationnow also strips the MAC's lease-file entry and restarts dnsmasq (persisting each bridge's cidr to a small state file so the restart doesn't needcidrthreaded through theDHCPManagerinterface).Found and reproduced live while wiring Windows/
chVM support intoboxctl-vms: the very first Windows VM created through the new integration hung on this exact bug.Test plan
go test ./internal/providerch/...β new regression testsTestDnsmasqDHCPManager_RemoveReservation_ClearsStaleLease/_NoMatchpass, existingTestDnsmasqDHCPManager_ReservationRoundTripunaffectedgo build ./...,go vet ./...,gofmt -lcleanπ€ Generated with Claude Code