Skip to content

Reconcile and DNS per host; wire incus_remote into migrate (#85) - #97

Merged
wmantly merged 3 commits into
mainfrom
feat/reconcile-dns-per-host
Nov 5, 2026
Merged

wmantly merged 3 commits into
mainfrom
feat/reconcile-dns-per-host

Conversation

@wmantly

@wmantly wmantly commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Closes #85. Part of #43.

What changed

Reconcile per host (pkg/engine/reconciler.go). The single primaryHostIP / hostSSHUser / hostSSHPort are gone. Each host is reconciled on its own, in sorted name order: it is provisioned (with its daemon from cloud-init, and --host-name when there are several hosts), then its Incus runtime is bootstrapped over SSH. Each host uses its own address, SSH user and port, and bridge.

  • With several hosts, a host that fails is logged and the others carry on. The run then fails at the end and names each host that failed (1 of 2 hosts failed: host alpha: ...).
  • The fleet domain's apex and wildcard point at the default host, not at whichever host came last in map order.
  • Single-host output and errors are unchanged. The first commit adds only test seams (SSH credentials, the SSH dial, the SSH wait, the DNS provider) and golden files generated from main's code. The second commit rewrites the loop, and the same goldens still pass: SSH, SSH plus --deploy-services, DNS failing, SSH failing, local, no address, and no hosts.

DNS follows the host. This replaces #89's stopgap, where the default host's daemon wrote every DNS record.

  • dns_records entries take service:. Such a record belongs to that service's host (host:, else default_host). An A or AAAA record tied to a service leaves out value: and gets the host's address:.
  • A service that is not on the default host and is routed under domain: gets an A record at its own host's address. Without it, the wildcard would send that name to the default host.
  • Every other record stays with the default host.
  • Each daemon plans and applies only its own records. Its plan notes the records each other host's daemon handles (note: dns: host h2's daemon plans and applies ...).
  • config.FleetConfig.DNSRecordsByHost holds the rules. Validation refuses, and the plan blocks on:
    • a wildcard tied to a service;
    • a service off the default host that is routed at a wildcard or at the apex;
    • any record that two hosts would claim (same zone, name and type, a CNAME next to another record of the same name, or a clash with domain:'s apex or wildcard);
    • a record tied to a service that doesn't exist;
    • an A or AAAA record tied to a service that also sets a value:;
    • a host with no IP address of the needed family.
  • native-ops dns sync writes the records of every host.

incus_remote is wired in, not removed.

  • Each deploy tag records fleet.yml's hosts and their incus_remote in <state-dir>/host-remotes.json.
  • POST /v1/instances/{name}/migrate now also takes {"target_host": "..."} and resolves it to that host's remote.
  • target_host is refused when:
    • it is sent together with target_remote;
    • no deploy has recorded the hosts yet;
    • the host is unknown;
    • the host has no incus_remote;
    • it names this daemon's own host.
  • target_remote works as before.
  • fleet.yml now checks the shape of incus_remote, refuses local, and refuses two hosts sharing one remote.

validate per host. With two or more hosts, native-ops validate lists each host's address, its services and the DNS records that point at it. A plan's per-host DNS section is the set of notes described above. Host names in validate output are now sorted.

Docs: docs/daemon.md gets new "DNS with several hosts" and "Reconcile with several hosts" sections. The Several hosts bullets, migrate (target_host), the state directory table and the roadmap are updated. The README's fleet.yml reference now covers incus_remote, address, and dns_records with service:.

For review

  • Ordering in reconcile. All hosts are provisioned first, then DNS is synced, then each host is bootstrapped. This keeps single-host output identical. A default host that fails provisioning means DNS is not synced, and that is reported. A failure during bootstrap does not undo DNS, same as before.
  • Route records are generated only for services off the default host whose domain is under domain:. External routes, routes on the default host, and routes outside the zone get no record. For a route outside the zone, declare a dns_records entry with service:.
  • Host addresses. A service-tied record or a generated route record needs hosts.<name>.address to be a literal IP. auto (DigitalOcean) is refused with a clear message, because the daemon has no other way to learn the address.
  • Errors from DNSRecordsByHost block the plan. They don't fail PlanFleet with bad_config. This keeps a single-host plan's existing "dns_records: no zone" blocker unchanged.
  • Sibling WireGuard mesh between hosts, with routes for each host's bridge subnet #84 (WireGuard mesh): this PR doesn't touch host bootstrap commands or cloud-init content. In reconciler.go, the Level-0 and bootstrap code moved into provisionHost and bootstrapHost, so a merge there should only need hunks moved into those functions.

Checks (all pass)

  • gofmt -l .: prints nothing
  • go mod tidy && git diff --exit-code go.mod go.sum: clean
  • go vet ./...: clean
  • go test -race ./...: all packages ok
  • node --check pkg/server/ui/static/js/app.js: ok
  • README CLI Usage matches the built binary (TestREADMECarriesTheUsage passes)

New tests:

  • reconcile over two hosts with a fake executor per host: order, per-host SSH and bridge, DNS to the default host, one host failing, the default host failing, both failing, DNS failing;
  • the single-host goldens;
  • DNS ownership as each daemon sees it, including that no record is planned by both;
  • per-host apply, then a re-plan that is empty on both hosts (idempotency);
  • validation refusals in config, engine plan and validate;
  • validate's per-host summary;
  • incus_remote validation;
  • target_host resolution, refusals and role gate;
  • a deploy recording the remotes.

No self-merge.

🤖 Generated with Claude Code

wmantly and others added 3 commits November 5, 2026 00:44
… the per-host loop

The Reconciler takes its SSH credentials, SSH sessions, SSH wait and DNS provider
from fields that tests replace. Behaviour is unchanged; the golden files in
pkg/engine/testdata are main's output for a single host, so the per-host loop
that follows can be checked against them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reconcile: each host of fleet.yml is reconciled on its own, in name order
(provision with its daemon from cloud-init, then its Incus runtime over SSH),
with its own address, SSH user/port and bridge. The single primaryHostIP,
hostSSHUser and hostSSHPort are gone. With several hosts a host that fails is
logged, the others carry on, and the run fails at the end naming each failed
host. The fleet domain's apex and wildcard point at the default host. A single
host reconciles exactly as before (golden files from the previous commit).

DNS follows the host, replacing #89's "the default host's daemon owns all
dns_records": a dns_records entry with `service:` belongs to that service's
host (an A/AAAA one takes the host's address), a route of a service off the
default host under `domain:` gets an A record at its host, and every other
record is the default host's. Each daemon plans and applies only its own
records and notes which host does the others. validate and the plan refuse a
wildcard tied to a service, a wildcard or apex route off the default host,
and any record two hosts would claim. `dns sync` writes every host's records.

incus_remote: a deploy records fleet.yml's hosts and their incus_remote in the
state directory (host-remotes.json); POST /v1/instances/{name}/migrate takes
target_host and resolves it to that remote. fleet.yml checks incus_remote's
shape and that no two hosts share one.

validate lists each host's address, services and DNS records when fleet.yml
has two or more hosts.

Closes #85. Part of #43.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… reconcile

Only the docs conflicted: README's node-02 example now shows both its
incus_remote and its mesh key, and the daemon.md roadmap lists the mesh,
DNS and reconcile per host, host-keyed backups and the migrate job as done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wmantly

wmantly commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged main in (951cb6d) after #95 and #96 landed. Only the docs conflicted, and both sides are kept:

  • README: the node-02 example shows its incus_remote and its mesh key;
  • docs/daemon.md: the roadmap lists the mesh, DNS and reconcile per host, host-keyed backups and the migrate job as done.

The full check set passes (gofmt, mod tidy, vet, go test -race ./..., node).

One full-suite run failed TestOfManySimultaneousAppliesExactlyOneRuns with accepted=1 refused=6 applied=1. It passed 30 out of 30 runs on its own on this branch, on main, and on main before #95, and the full suite passed on rerun. The invariant held: exactly one apply ran. The test counts only 202 and 409, so one of the eight requests got a different answer under load, most likely a 429 from the plan or queue limits. That is a test-accounting flake, not related to this PR.


Drafted by William's agent (Claude).

@wmantly
wmantly merged commit ad27566 into main Nov 5, 2026
1 check passed
@wmantly
wmantly deleted the feat/reconcile-dns-per-host branch November 5, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reconcile and DNS per host (drop the single primaryHostIP; wire or remove incus_remote)

1 participant