network: Try removing as many changes as possible during network cleanup

In case an error is encountered while removing a network endpoint during
network cleanup, we cuurently return immediately with the error.
With this change, in case of error we simply log the error and proceed
towards removing the next endpoint. With this, we can cleanup the
network changes made by the shim as much as possible.
This is especially important when multiple interfaces are passed to the
network namespace using a network plugin like multus.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
Archana Shinde
2023-12-12 21:11:54 -08:00
parent b005cda689
commit 6d38fa1530

View File

@@ -437,7 +437,12 @@ func (n *LinuxNetwork) RemoveEndpoints(ctx context.Context, s *Sandbox, endpoint
}
if err := n.removeSingleEndpoint(ctx, s, ep, hotplug); err != nil {
return err
// Log the error instead of returning right away
// Proceed to remove the next endpoint so as to clean the network setup as
// much as possible.
// This is crucial for physical endpoints as we want to bind back the physical
// interface to its original host driver.
networkLogger().Warnf("Error removing endpoint %v : %v", ep.Name(), err)
}
}