Merge pull request #46226 from thaJeztah/conntrack_reduce_noise

libnetwork/iptables: reduce DeleteConntrackEntriesXX debug logs
This commit is contained in:
Sebastiaan van Stijn 2023-08-23 14:19:53 +02:00 committed by GitHub
commit 8f0b62e4d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,9 +25,9 @@ func checkConntrackProgrammable(nlh *netlink.Handle) error {
// DeleteConntrackEntries deletes all the conntrack connections on the host for the specified IP
// Returns the number of flows deleted for IPv4, IPv6 else error
func DeleteConntrackEntries(nlh *netlink.Handle, ipv4List []net.IP, ipv6List []net.IP) (uint, uint, error) {
func DeleteConntrackEntries(nlh *netlink.Handle, ipv4List []net.IP, ipv6List []net.IP) error {
if err := checkConntrackProgrammable(nlh); err != nil {
return 0, 0, err
return err
}
var totalIPv4FlowPurged uint
@ -50,8 +50,11 @@ func DeleteConntrackEntries(nlh *netlink.Handle, ipv4List []net.IP, ipv6List []n
totalIPv6FlowPurged += flowPurged
}
log.G(context.TODO()).Debugf("DeleteConntrackEntries purged ipv4:%d, ipv6:%d", totalIPv4FlowPurged, totalIPv6FlowPurged)
return totalIPv4FlowPurged, totalIPv6FlowPurged, nil
if totalIPv4FlowPurged > 0 || totalIPv6FlowPurged > 0 {
log.G(context.TODO()).Debugf("DeleteConntrackEntries purged ipv4:%d, ipv6:%d", totalIPv4FlowPurged, totalIPv6FlowPurged)
}
return nil
}
func DeleteConntrackEntriesByPort(nlh *netlink.Handle, proto types.Protocol, ports []uint16) error {
@ -86,7 +89,10 @@ func DeleteConntrackEntriesByPort(nlh *netlink.Handle, proto types.Protocol, por
totalIPv6FlowPurged += v6FlowPurged
}
log.G(context.TODO()).Debugf("DeleteConntrackEntriesByPort for %s ports purged ipv4:%d, ipv6:%d", proto.String(), totalIPv4FlowPurged, totalIPv6FlowPurged)
if totalIPv4FlowPurged > 0 || totalIPv6FlowPurged > 0 {
log.G(context.TODO()).Debugf("DeleteConntrackEntriesByPort for %s ports purged ipv4:%d, ipv6:%d", proto.String(), totalIPv4FlowPurged, totalIPv6FlowPurged)
}
return nil
}