From 900d25bab2ecd7e2289614539d2520e3ad8b4e34 Mon Sep 17 00:00:00 2001 From: Paul Payne Date: Thu, 9 Jul 2026 15:54:34 +0000 Subject: [PATCH] fix: Reload dnsmasq instead of restart to avoid DNS downtime Use systemctl reload-or-restart instead of restart. dnsmasq supports SIGHUP to reload config without dropping DNS service, preventing transient DNS resolution failures during reconciliation. Co-Authored-By: Claude Opus 4.6 (1M context) --- internal/dnsmasq/config.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/dnsmasq/config.go b/internal/dnsmasq/config.go index 1add4c1..5c89b3a 100644 --- a/internal/dnsmasq/config.go +++ b/internal/dnsmasq/config.go @@ -104,14 +104,15 @@ func (g *ConfigGenerator) WriteConfig(cfg *config.GlobalConfig, clouds []config. return nil } -// RestartService restarts the dnsmasq service +// RestartService reloads the dnsmasq service (SIGHUP — no downtime). +// Falls back to restart if reload fails. func (g *ConfigGenerator) RestartService() error { - cmd := exec.Command("systemctl", "restart", "dnsmasq.service") + cmd := exec.Command("systemctl", "reload-or-restart", "dnsmasq.service") output, err := cmd.CombinedOutput() if err != nil { - return fmt.Errorf("failed to restart dnsmasq: %w (output: %s)", err, string(output)) + return fmt.Errorf("failed to reload dnsmasq: %w (output: %s)", err, string(output)) } - slog.Info("dnsmasq service restarted", "component", "dnsmasq") + slog.Info("dnsmasq service reloaded", "component", "dnsmasq") return nil }