Merge pull request #95694 from aojea/conntracklog

Log conntrack operations
This commit is contained in:
Kubernetes Prow Robot 2020-10-19 03:20:13 -07:00 committed by GitHub
commit 5f2ebe4bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View File

@ -1625,11 +1625,13 @@ func (proxier *Proxier) syncProxyRules() {
// Finish housekeeping.
// TODO: these could be made more consistent.
klog.V(4).Infof("Deleting stale services IPs: %v", staleServices.UnsortedList())
for _, svcIP := range staleServices.UnsortedList() {
if err := conntrack.ClearEntriesForIP(proxier.exec, svcIP, v1.ProtocolUDP); err != nil {
klog.Errorf("Failed to delete stale service IP %s connections, error: %v", svcIP, err)
}
}
klog.V(4).Infof("Deleting stale endpoint connections: %v", endpointUpdateResult.StaleEndpoints)
proxier.deleteEndpointConnections(endpointUpdateResult.StaleEndpoints)
}

View File

@ -7,6 +7,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/klog/v2:go_default_library",
"//vendor/k8s.io/utils/exec:go_default_library",
"//vendor/k8s.io/utils/net:go_default_library",
],

View File

@ -22,6 +22,7 @@ import (
"strings"
v1 "k8s.io/api/core/v1"
"k8s.io/klog/v2"
"k8s.io/utils/exec"
utilnet "k8s.io/utils/net"
)
@ -62,10 +63,12 @@ func Exec(execer exec.Interface, parameters ...string) error {
if err != nil {
return fmt.Errorf("error looking for path of conntrack: %v", err)
}
klog.V(4).Infof("Clearing conntrack entries %v", parameters)
output, err := execer.Command(conntrackPath, parameters...).CombinedOutput()
if err != nil {
return fmt.Errorf("conntrack command returned: %q, error message: %s", string(output), err)
}
klog.V(4).Infof("Conntrack entries deleted %s", string(output))
return nil
}