From 6128d1ebda8d4f851e5a5946d4f555ba0f920a78 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 3 Dec 2020 16:49:26 +0100 Subject: [PATCH] Remove error logging for deleteFromNetwork call While working on podman#8571 I noticed that calling `deleteFromNetwork` logs the same error twice. For example it errors if the iptables rules do not exists and this creates a very verbose error. Since the error is returned I do not see any point in logging it. The caller should decide if the error should be logged or not. It is super confusing for users to get a error logged when they have no control to change anything. In case of podman#8571 the user would only want to call this if the iptables rules are flushed, getting a error in this case is super confusing. Signed-off-by: Paul Holzinger --- pkg/ocicni/ocicni.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/ocicni/ocicni.go b/pkg/ocicni/ocicni.go index 7a9f97d1..5a9bf132 100644 --- a/pkg/ocicni/ocicni.go +++ b/pkg/ocicni/ocicni.go @@ -637,8 +637,7 @@ func (plugin *cniNetworkPlugin) TearDownPodWithContext(ctx context.Context, podN return plugin.forEachNetwork(&podNetwork, true, func(network *cniNetwork, podNetwork *PodNetwork, rt *libcni.RuntimeConf) error { if err := network.deleteFromNetwork(ctx, rt, plugin.cniConfig); err != nil { - logrus.Errorf("Error while removing pod from CNI network %q: %s", network.name, err) - return err + return fmt.Errorf("Error while removing pod from CNI network %q: %s", network.name, err) } return nil }) @@ -771,7 +770,6 @@ func (network *cniNetwork) checkNetwork(ctx context.Context, rt *libcni.RuntimeC func (network *cniNetwork) deleteFromNetwork(ctx context.Context, rt *libcni.RuntimeConf, cni *libcni.CNIConfig) error { logrus.Infof("About to del CNI network %s (type=%v)", network.name, network.config.Plugins[0].Network.Type) if err := cni.DelNetworkList(ctx, network.config, rt); err != nil { - logrus.Errorf("Error deleting network: %v", err) return err } return nil