From 57cf276d3167ce2e53f3e9786bb237b1f9d85e65 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Mon, 23 Mar 2026 14:03:30 +0000 Subject: [PATCH] chore(firewall/iptables): log restore data on failure to restore --- internal/firewall/iptables/atomic.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/firewall/iptables/atomic.go b/internal/firewall/iptables/atomic.go index 5e6a995c..a8ec46e5 100644 --- a/internal/firewall/iptables/atomic.go +++ b/internal/firewall/iptables/atomic.go @@ -54,7 +54,7 @@ func (c *Config) saveAndRestoreIPv4(ctx context.Context) (restore func(context.C cmd.Stdin = strings.NewReader(data) output, err := c.runner.Run(cmd) if err != nil { - c.logger.Warn(fmt.Sprintf("restoring IPv4 iptables failed: %v: %s", err, output)) + c.logger.Warn(fmt.Sprintf("restoring IPv4 iptables failed: %s", makeRestoreErrorMessage(err, output, data))) } } return restore, nil @@ -78,8 +78,12 @@ func (c *Config) saveAndRestoreIPv6(ctx context.Context) (restore func(context.C cmd.Stdin = strings.NewReader(data) output, err := c.runner.Run(cmd) if err != nil { - c.logger.Warn(fmt.Sprintf("restoring IPv6 iptables failed: %v: %s", err, output)) + c.logger.Warn(fmt.Sprintf("restoring IPv6 iptables failed: %s", makeRestoreErrorMessage(err, output, data))) } } return restore, nil } + +func makeRestoreErrorMessage(err error, output, data string) string { + return fmt.Sprintf("%s: %s: restoring from data:\n%s", err, output, data) +}