libnetwork/osl: Namespace.DeleteNeighbor: don't warn on non-existing neighbor
The code ignores these errors, but will unconditionally print a warning; > If the kernel deletion fails for the neighbor entry still remote it > from the namespace cache. Otherwise if the neighbor moves back to the > same host again, kernel update can fail. Let's reduce noise if the neighbor wasn't found, to prevent logs like: Aug 16 13:26:35 master1.local dockerd[4019880]: time="2023-08-16T13:26:35.186662370+02:00" level=warning msg="error while deleting neighbor entry" error="no such file or directory" Aug 16 13:26:35 master1.local dockerd[4019880]: time="2023-08-16T13:26:35.366585939+02:00" level=warning msg="error while deleting neighbor entry" error="no such file or directory" Aug 16 13:26:42 master1.local dockerd[4019880]: time="2023-08-16T13:26:42.366658513+02:00" level=warning msg="error while deleting neighbor entry" error="no such file or directory" While changing this code, also slightly rephrase the code-comment, and fix a typo ("remote -> remove"). Signed-off-by: Sebastiaan van Stijn <github@gone.nl> libnetwork/osl: Namespace.DeleteNeighbor: rephrase code-comment Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
6ce5aa1cd5
commit
bc77104fed
1 changed files with 7 additions and 5 deletions
|
@ -3,8 +3,10 @@ package osl
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/vishvananda/netlink"
|
||||
|
@ -82,10 +84,10 @@ func (n *Namespace) DeleteNeighbor(dstIP net.IP, dstMac net.HardwareAddr, osDele
|
|||
nlnh.LinkIndex = iface.Attrs().Index
|
||||
}
|
||||
|
||||
// If the kernel deletion fails for the neighbor entry still remote it
|
||||
// from the namespace cache. Otherwise if the neighbor moves back to the
|
||||
// same host again, kernel update can fail.
|
||||
if err := nlh.NeighDel(nlnh); err != nil {
|
||||
// If the kernel deletion fails for the neighbor entry still remove it
|
||||
// from the namespace cache, otherwise kernel update can fail if the
|
||||
// neighbor moves back to the same host again.
|
||||
if err := nlh.NeighDel(nlnh); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
log.G(context.TODO()).Warnf("Deleting neighbor IP %s, mac %s failed, %v", dstIP, dstMac, err)
|
||||
}
|
||||
|
||||
|
@ -101,7 +103,7 @@ func (n *Namespace) DeleteNeighbor(dstIP net.IP, dstMac net.HardwareAddr, osDele
|
|||
if nh.linkDst != "" {
|
||||
nlnh.LinkIndex = iface.Attrs().Index
|
||||
}
|
||||
if err := nlh.NeighDel(nlnh); err != nil {
|
||||
if err := nlh.NeighDel(nlnh); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
log.G(context.TODO()).WithError(err).Warn("error while deleting neighbor entry")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue