diff -up kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/cni.go.fix_for_cni kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/cni.go
--- kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/cni.go.fix_for_cni 2019-06-15 02:58:09.000000000 +0200
+++ kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/cni.go 2019-07-09 00:05:56.196711576 +0200
@@ -17,6 +17,7 @@ limitations under the License.
package cni
import (
+ "context"
"encoding/json"
"errors"
"fmt"
@@ -326,7 +327,7 @@ func (plugin *cniNetworkPlugin) addToNet
pdesc := podDesc(podNamespace, podName, podSandboxID)
netConf, cniNet := network.NetworkConfig, network.CNIConfig
klog.V(4).Infof("Adding %s to network %s/%s netns %q", pdesc, netConf.Plugins[0].Network.Type, netConf.Name, podNetnsPath)
- res, err := cniNet.AddNetworkList(netConf, rt)
+ res, err := cniNet.AddNetworkList(context.TODO(), netConf, rt)
if err != nil {
klog.Errorf("Error adding %s to network %s/%s: %v", pdesc, netConf.Plugins[0].Network.Type, netConf.Name, err)
return nil, err
@@ -345,7 +346,7 @@ func (plugin *cniNetworkPlugin) deleteFr
pdesc := podDesc(podNamespace, podName, podSandboxID)
netConf, cniNet := network.NetworkConfig, network.CNIConfig
klog.V(4).Infof("Deleting %s from network %s/%s netns %q", pdesc, netConf.Plugins[0].Network.Type, netConf.Name, podNetnsPath)
- err = cniNet.DelNetworkList(netConf, rt)
+ err = cniNet.DelNetworkList(context.TODO(), netConf, rt)
// The pod may not get deleted successfully at the first time.
// Ignore "no such file or directory" error in case the network has already been deleted in previous attempts.
if err != nil && !strings.Contains(err.Error(), "no such file or directory") {
diff -up kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/cni_test.go.fix_for_cni kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/cni_test.go
--- kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/cni_test.go.fix_for_cni 2019-06-15 02:58:09.000000000 +0200
+++ kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/cni_test.go 2019-07-09 00:05:56.197711570 +0200
@@ -20,6 +20,7 @@ package cni
import (
"bytes"
+ "context"
"encoding/json"
"fmt"
"io/ioutil"
@@ -217,7 +218,7 @@ func TestCNIPlugin(t *testing.T) {
cniPlugin.execer = fexec
cniPlugin.loNetwork.CNIConfig = mockLoCNI
- mockLoCNI.On("AddNetworkList", cniPlugin.loNetwork.NetworkConfig, mock.AnythingOfType("*libcni.RuntimeConf")).Return(&types020.Result{IP4: &types020.IPConfig{IP: net.IPNet{IP: []byte{127, 0, 0, 1}}}}, nil)
+ mockLoCNI.On("AddNetworkList", context.TODO(), cniPlugin.loNetwork.NetworkConfig, mock.AnythingOfType("*libcni.RuntimeConf")).Return(&types020.Result{IP4: &types020.IPConfig{IP: net.IPNet{IP: []byte{127, 0, 0, 1}}}}, nil)
// Check that status returns an error
if err := cniPlugin.Status(); err == nil {
diff -up kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/testing/mock_cni.go.fix_for_cni kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/testing/mock_cni.go
--- kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/testing/mock_cni.go.fix_for_cni 2019-06-15 02:58:09.000000000 +0200
+++ kubernetes-1.15.0/pkg/kubelet/dockershim/network/cni/testing/mock_cni.go 2019-07-09 00:05:56.198711563 +0200
@@ -19,6 +19,8 @@ limitations under the License.
package mock_cni
import (
+ "context"
+
"github.com/containernetworking/cni/libcni"
"github.com/containernetworking/cni/pkg/types"
"github.com/stretchr/testify/mock"
@@ -28,22 +30,22 @@ type MockCNI struct {
mock.Mock
}
-func (m *MockCNI) AddNetwork(net *libcni.NetworkConfig, rt *libcni.RuntimeConf) (types.Result, error) {
- args := m.Called(net, rt)
+func (m *MockCNI) AddNetwork(ctx context.Context, net *libcni.NetworkConfig, rt *libcni.RuntimeConf) (types.Result, error) {
+ args := m.Called(ctx, net, rt)
return args.Get(0).(types.Result), args.Error(1)
}
-func (m *MockCNI) DelNetwork(net *libcni.NetworkConfig, rt *libcni.RuntimeConf) error {
- args := m.Called(net, rt)
+func (m *MockCNI) DelNetwork(ctx context.Context, net *libcni.NetworkConfig, rt *libcni.RuntimeConf) error {
+ args := m.Called(ctx, net, rt)
return args.Error(0)
}
-func (m *MockCNI) DelNetworkList(net *libcni.NetworkConfigList, rt *libcni.RuntimeConf) error {
- args := m.Called(net, rt)
+func (m *MockCNI) DelNetworkList(ctx context.Context, net *libcni.NetworkConfigList, rt *libcni.RuntimeConf) error {
+ args := m.Called(ctx, net, rt)
return args.Error(0)
}
-func (m *MockCNI) AddNetworkList(net *libcni.NetworkConfigList, rt *libcni.RuntimeConf) (types.Result, error) {
- args := m.Called(net, rt)
+func (m *MockCNI) AddNetworkList(ctx context.Context, net *libcni.NetworkConfigList, rt *libcni.RuntimeConf) (types.Result, error) {
+ args := m.Called(ctx, net, rt)
return args.Get(0).(types.Result), args.Error(1)
}
diff -up kubernetes-1.15.0/pkg/kubelet/dockershim/network/kubenet/kubenet_linux.go.fix_for_cni kubernetes-1.15.0/pkg/kubelet/dockershim/network/kubenet/kubenet_linux.go
--- kubernetes-1.15.0/pkg/kubelet/dockershim/network/kubenet/kubenet_linux.go.fix_for_cni 2019-06-15 02:58:09.000000000 +0200
+++ kubernetes-1.15.0/pkg/kubelet/dockershim/network/kubenet/kubenet_linux.go 2019-07-09 00:05:56.200711551 +0200
@@ -19,6 +19,7 @@ limitations under the License.
package kubenet
import (
+ "context"
"fmt"
"io/ioutil"
"net"
@@ -570,7 +571,7 @@ func (plugin *kubenetNetworkPlugin) addC
// 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)
+ res, err := plugin.cniConfig.AddNetwork(context.TODO(), config, rt)
plugin.mu.Lock()
if err != nil {
return nil, fmt.Errorf("Error adding container to network: %v", err)
@@ -585,7 +586,7 @@ func (plugin *kubenetNetworkPlugin) delC
}
klog.V(3).Infof("Removing %s/%s from '%s' with CNI '%s' plugin and runtime: %+v", namespace, name, config.Network.Name, config.Network.Type, rt)
- err = plugin.cniConfig.DelNetwork(config, rt)
+ err = plugin.cniConfig.DelNetwork(context.TODO(), config, rt)
// The pod may not get deleted successfully at the first time.
// Ignore "no such file or directory" error in case the network has already been deleted in previous attempts.
if err != nil && !strings.Contains(err.Error(), "no such file or directory") {