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
pull/6/head
Casey Callendrello 2017-10-30 15:55:26 +00:00
parent 6659f2a7d8
commit 256d6cc83a
1 changed files with 4 additions and 0 deletions

View File

@ -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)
}