Replace mapdns with daemon DNS
Serve daemon-managed .vm names directly from bangerd on 127.0.0.1:42069 instead of shelling out to mapdns. This keeps DNS state tied to VM lifecycle and lets the daemon rebuild records from running VMs after startup or reconcile. Add a small in-process authoritative DNS server, register and remove records from the VM start/stop/delete paths, and show the listener in daemon status. Remove the mapdns config and preflight surface, stop helper-flow DNS publishing in customize.sh and interactive.sh, drop dns.sh from the runtime bundle, and update docs/tests for the new local-resolver integration model. Validated with GOCACHE=/tmp/banger-gocache go test ./..., GOCACHE=/tmp/banger-gocache make build, and bash -n customize.sh interactive.sh.
This commit is contained in:
parent
430f66d5dd
commit
0a0b0b617b
24 changed files with 576 additions and 278 deletions
|
|
@ -15,6 +15,7 @@ import (
|
|||
"banger/internal/model"
|
||||
"banger/internal/paths"
|
||||
"banger/internal/store"
|
||||
"banger/internal/vmdns"
|
||||
)
|
||||
|
||||
func TestFindVMPrefixResolution(t *testing.T) {
|
||||
|
|
@ -143,6 +144,65 @@ func TestReconcileStopsStaleRunningVMAndClearsRuntimeHandles(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRebuildDNSIncludesOnlyLiveRunningVMs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx := context.Background()
|
||||
db := openDaemonStore(t)
|
||||
|
||||
liveSock := filepath.Join(t.TempDir(), "live.sock")
|
||||
liveCmd := startFakeFirecrackerProcess(t, liveSock)
|
||||
t.Cleanup(func() {
|
||||
_ = liveCmd.Process.Kill()
|
||||
_ = liveCmd.Wait()
|
||||
})
|
||||
|
||||
live := testVM("live", "image-live", "172.16.0.21")
|
||||
live.State = model.VMStateRunning
|
||||
live.Runtime.State = model.VMStateRunning
|
||||
live.Runtime.PID = liveCmd.Process.Pid
|
||||
live.Runtime.APISockPath = liveSock
|
||||
|
||||
stale := testVM("stale", "image-stale", "172.16.0.22")
|
||||
stale.State = model.VMStateRunning
|
||||
stale.Runtime.State = model.VMStateRunning
|
||||
stale.Runtime.PID = 999999
|
||||
stale.Runtime.APISockPath = filepath.Join(t.TempDir(), "stale.sock")
|
||||
|
||||
stopped := testVM("stopped", "image-stopped", "172.16.0.23")
|
||||
|
||||
for _, vm := range []model.VMRecord{live, stale, stopped} {
|
||||
if err := db.UpsertVM(ctx, vm); err != nil {
|
||||
t.Fatalf("UpsertVM(%s): %v", vm.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
server, err := vmdns.New("127.0.0.1:0", nil)
|
||||
if err != nil {
|
||||
t.Fatalf("vmdns.New: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
if err := server.Close(); err != nil {
|
||||
t.Fatalf("server.Close: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
d := &Daemon{store: db, vmDNS: server}
|
||||
if err := d.rebuildDNS(ctx); err != nil {
|
||||
t.Fatalf("rebuildDNS: %v", err)
|
||||
}
|
||||
|
||||
if _, ok := server.Lookup("live.vm"); !ok {
|
||||
t.Fatal("live.vm missing after rebuildDNS")
|
||||
}
|
||||
if _, ok := server.Lookup("stale.vm"); ok {
|
||||
t.Fatal("stale.vm should not be published")
|
||||
}
|
||||
if _, ok := server.Lookup("stopped.vm"); ok {
|
||||
t.Fatal("stopped.vm should not be published")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetVMRejectsStoppedOnlyChangesForRunningVM(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
@ -316,7 +376,7 @@ func TestValidateStartPrereqsReportsNATUplinkFailure(t *testing.T) {
|
|||
for _, name := range []string{
|
||||
"sudo", "ip", "dmsetup", "losetup", "blockdev", "truncate", "pgrep", "ps",
|
||||
"chown", "chmod", "kill", "e2cp", "e2rm", "debugfs", "mkfs.ext4", "mount",
|
||||
"umount", "cp", "iptables", "sysctl", "mapdns",
|
||||
"umount", "cp", "iptables", "sysctl",
|
||||
} {
|
||||
writeFakeExecutable(t, filepath.Join(binDir, name))
|
||||
}
|
||||
|
|
@ -339,7 +399,6 @@ func TestValidateStartPrereqsReportsNATUplinkFailure(t *testing.T) {
|
|||
runner: runner,
|
||||
config: model.DaemonConfig{
|
||||
FirecrackerBin: firecrackerBin,
|
||||
MapDNSBin: "mapdns",
|
||||
},
|
||||
}
|
||||
vm := testVM("nat", "image-nat", "172.16.0.12")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue