Skip to content

feat(dns): migrate DNS writes from resolvectl to persistent Netplan#348

Merged
retr0h merged 8 commits intomainfrom
feat/dns-netplan-migration
Apr 3, 2026
Merged

feat(dns): migrate DNS writes from resolvectl to persistent Netplan#348
retr0h merged 8 commits intomainfrom
feat/dns-netplan-migration

Conversation

@retr0h
Copy link
Copy Markdown
Collaborator

@retr0h retr0h commented Apr 3, 2026

Summary

  • DNS write operations now generate /etc/netplan/osapi-dns.yaml instead of runtime resolvectl commands — changes persist across reboots
  • New shared netplan.ApplyConfig helper handles the write → validate → apply flow with automatic rollback on netplan generate failure
  • Read path stays on resolvectl (shows current runtime state)
  • Container DNS provider unchanged (uses /etc/resolv.conf directly)
  • API endpoint shape unchanged (PUT /network/dns) — no SDK or CLI changes needed

Netplan write flow

  1. Generate Netplan YAML from structured input
  2. Check SHA for idempotency (skip if unchanged)
  3. Write file to /etc/netplan/osapi-dns.yaml
  4. Run netplan generate — validates merged config
  5. If validation fails → delete file, return error
  6. Run netplan apply — applies validated config
  7. Store state in file-state KV

Establishes pattern for

  • Network interface management (next spec)
  • Route management (next spec)

Both will reuse netplan.ApplyConfig and the same file-per-concern pattern.

Test plan

  • Shared netplan helper: 100% coverage (ApplyConfig, RemoveConfig, ComputeSHA256)
  • DNS write tests: success, idempotent, generate fails, empty input
  • YAML generation tests: servers+domains, servers only, domains only, interface name, IPv6
  • Build clean, lint clean
  • All existing DNS read tests still pass

🤖 Generated with Claude Code

retr0h and others added 5 commits April 2, 2026 21:43
Add a reusable netplan package with write-validate-apply flow,
rollback on validation failure, and file-state KV tracking.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add avfs.VFS, jetstream.KeyValue, and hostname fields to the DNS
Debian provider struct and constructor. These dependencies are needed
for upcoming Netplan DNS write support. Move file provider creation
earlier in agent_setup.go so fileStateKV and hostname are available
when the DNS provider is constructed.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace the DNS write path (UpdateResolvConfByInterface) from
resolvectl commands to Netplan YAML generation. The read path
still uses resolvectl for querying current DNS state. Writes now
generate /etc/netplan/osapi-dns.yaml and apply via the shared
netplan.ApplyConfig helper with SHA-based idempotency.

Co-Authored-By: Claude <noreply@anthropic.com>
Add export bridge and public test suite for generateDNSNetplanYAML,
dnsNetplanPath, and resolvePrimaryInterface covering servers-only,
search-domains-only, combined, IPv6, and facts-based interface
resolution scenarios.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
DNS write operations now generate /etc/netplan/osapi-dns.yaml,
validate with netplan generate, and apply with netplan apply.
Reads stay on resolvectl. Shared netplan.ApplyConfig helper
established for interface and route management to reuse.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
retr0h and others added 3 commits April 2, 2026 22:05
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Expand the supported contexts section to explain that fact
resolution is universal — any string in any request gets resolved
agent-side. Add array and broadcast examples.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #348   +/-   ##
=======================================
  Coverage   99.91%   99.91%           
=======================================
  Files         441      443    +2     
  Lines       21510    21606   +96     
=======================================
+ Hits        21491    21587   +96     
  Misses         11       11           
  Partials        8        8           
Files with missing lines Coverage Δ
internal/provider/network/dns/debian.go 100.00% <100.00%> (ø)
internal/provider/network/dns/debian_netplan.go 100.00% <100.00%> (ø)
...work/dns/debian_update_resolv_conf_by_interface.go 100.00% <100.00%> (ø)
internal/provider/network/netplan/netplan.go 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d91871f...6077ffb. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@retr0h retr0h merged commit e01cc5e into main Apr 3, 2026
11 checks passed
@retr0h retr0h deleted the feat/dns-netplan-migration branch April 3, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant