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) <noreply@anthropic.com>
This commit is contained in:
2026-07-09 15:54:34 +00:00
parent ed0691d56f
commit 900d25bab2

View File

@@ -104,14 +104,15 @@ func (g *ConfigGenerator) WriteConfig(cfg *config.GlobalConfig, clouds []config.
return nil 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 { 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() output, err := cmd.CombinedOutput()
if err != nil { 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 return nil
} }