From 256d6cc83a0f1550eb8b30837498911326dc8480 Mon Sep 17 00:00:00 2001 From: Casey Callendrello Date: Mon, 30 Oct 2017 15:55:26 +0000 Subject: [PATCH] kubenet: yield lock while executing CNI plugin. The CNI plugin can take up to 3 seconds to execute. CNI plugins can safely be executed in parallel, so yield the lock to speed up pod creation. Fixes: #54651 --- pkg/kubelet/network/kubenet/kubenet_linux.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/kubelet/network/kubenet/kubenet_linux.go b/pkg/kubelet/network/kubenet/kubenet_linux.go index d7a9f836e5c..fce972d0044 100644 --- a/pkg/kubelet/network/kubenet/kubenet_linux.go +++ b/pkg/kubelet/network/kubenet/kubenet_linux.go @@ -744,7 +744,11 @@ func (plugin *kubenetNetworkPlugin) addContainerToNetwork(config *libcni.Network } glog.V(3).Infof("Adding %s/%s to '%s' with CNI '%s' plugin and runtime: %+v", namespace, name, config.Network.Name, config.Network.Type, rt) + // The network plugin can take up to 3 seconds to execute, + // so yield the lock while it runs. + plugin.mu.Unlock() res, err := plugin.cniConfig.AddNetwork(config, rt) + plugin.mu.Lock() if err != nil { return nil, fmt.Errorf("Error adding container to network: %v", err) }