From 6d38fa1530d9d8a64dbd2539768ecbe0a6d978b3 Mon Sep 17 00:00:00 2001 From: Archana Shinde Date: Tue, 12 Dec 2023 21:11:54 -0800 Subject: [PATCH] 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 --- src/runtime/virtcontainers/network_linux.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/runtime/virtcontainers/network_linux.go b/src/runtime/virtcontainers/network_linux.go index 74ba0659e2..161abc08cb 100644 --- a/src/runtime/virtcontainers/network_linux.go +++ b/src/runtime/virtcontainers/network_linux.go @@ -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) } }