libnetwork/iptables: reduce DeleteConntrackEntriesXX debug logs

Both functions were generating debug logs if there was nothing to log.
The function already produces logs if things failed while deleting entries,
so these logs would only be printed if there was nothing to delete, so can
safely be discarded.

Before this change:

    DEBU[2023-08-14T12:33:23.082052638Z] Revoking external connectivity on endpoint sweet_swirles (1519f9376a3abe7a1c981600c25e8df6bbd0a3bc3a074f1c2b3bcbad0438443b)
    DEBU[2023-08-14T12:33:23.085782847Z] DeleteConntrackEntries purged ipv4:0, ipv6:0
    DEBU[2023-08-14T12:33:23.085793847Z] DeleteConntrackEntriesByPort for udp ports purged ipv4:0, ipv6:0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-08-14 16:51:43 +02:00
parent 7b28bc51e6
commit f1240393d9
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -50,7 +50,10 @@ 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)
if totalIPv4FlowPurged > 0 || totalIPv6FlowPurged > 0 {
log.G(context.TODO()).Debugf("DeleteConntrackEntries purged ipv4:%d, ipv6:%d", totalIPv4FlowPurged, totalIPv6FlowPurged)
}
return totalIPv4FlowPurged, totalIPv6FlowPurged, nil
}
@ -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
}