kube-proxy should log the payload when iptables-restore fails

Signed-off-by: cyclinder <qifeng.guo@daocloud.io>
This commit is contained in:
cyclinder
2021-12-17 17:40:56 +08:00
parent 712745cb67
commit 97bd6e977d
4 changed files with 165 additions and 3 deletions

View File

@@ -1515,7 +1515,12 @@ func (proxier *Proxier) syncProxyRules() {
klog.V(5).InfoS("Restoring iptables", "rules", proxier.iptablesData.Bytes())
err = proxier.iptables.RestoreAll(proxier.iptablesData.Bytes(), utiliptables.NoFlushTables, utiliptables.RestoreCounters)
if err != nil {
klog.ErrorS(err, "Failed to execute iptables-restore")
if pErr, ok := err.(utiliptables.ParseError); ok {
lines := utiliptables.ExtractLines(proxier.iptablesData.Bytes(), pErr.Line(), 3)
klog.ErrorS(pErr, "Failed to execute iptables-restore", "rules", lines)
} else {
klog.ErrorS(err, "Failed to execute iptables-restore")
}
metrics.IptablesRestoreFailuresTotal.Inc()
// Revert new local ports.
klog.V(2).InfoS("Closing local ports after iptables-restore failure")