Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
946aff88
Commit
946aff88
authored
Aug 15, 2018
by
Pengfei Ni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dns capabilities to CNI for windows containers
parent
9c9eb2af
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
77 additions
and
23 deletions
+77
-23
docker_sandbox.go
pkg/kubelet/dockershim/docker_sandbox.go
+11
-2
docker_service_test.go
pkg/kubelet/dockershim/docker_service_test.go
+0
-1
cni.go
pkg/kubelet/dockershim/network/cni/cni.go
+33
-7
cni_others.go
pkg/kubelet/dockershim/network/cni/cni_others.go
+6
-0
cni_test.go
pkg/kubelet/dockershim/network/cni/cni_test.go
+1
-1
cni_windows.go
pkg/kubelet/dockershim/network/cni/cni_windows.go
+15
-1
kubenet_linux.go
pkg/kubelet/dockershim/network/kubenet/kubenet_linux.go
+1
-1
kubenet_unsupported.go
...kubelet/dockershim/network/kubenet/kubenet_unsupported.go
+1
-1
plugins.go
pkg/kubelet/dockershim/network/plugins.go
+4
-4
mock_network_plugin.go
...kubelet/dockershim/network/testing/mock_network_plugin.go
+1
-1
plugins_test.go
pkg/kubelet/dockershim/network/testing/plugins_test.go
+4
-4
No files found.
pkg/kubelet/dockershim/docker_sandbox.go
View file @
946aff88
...
@@ -18,6 +18,7 @@ package dockershim
...
@@ -18,6 +18,7 @@ package dockershim
import
(
import
(
"context"
"context"
"encoding/json"
"fmt"
"fmt"
"os"
"os"
"strings"
"strings"
...
@@ -27,7 +28,6 @@ import (
...
@@ -27,7 +28,6 @@ import (
dockercontainer
"github.com/docker/docker/api/types/container"
dockercontainer
"github.com/docker/docker/api/types/container"
dockerfilters
"github.com/docker/docker/api/types/filters"
dockerfilters
"github.com/docker/docker/api/types/filters"
"github.com/golang/glog"
"github.com/golang/glog"
utilerrors
"k8s.io/apimachinery/pkg/util/errors"
utilerrors
"k8s.io/apimachinery/pkg/util/errors"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager"
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager"
...
@@ -165,7 +165,16 @@ func (ds *dockerService) RunPodSandbox(ctx context.Context, r *runtimeapi.RunPod
...
@@ -165,7 +165,16 @@ func (ds *dockerService) RunPodSandbox(ctx context.Context, r *runtimeapi.RunPod
// on the host as well, to satisfy parts of the pod spec that aren't
// on the host as well, to satisfy parts of the pod spec that aren't
// recognized by the CNI standard yet.
// recognized by the CNI standard yet.
cID
:=
kubecontainer
.
BuildContainerID
(
runtimeName
,
createResp
.
ID
)
cID
:=
kubecontainer
.
BuildContainerID
(
runtimeName
,
createResp
.
ID
)
err
=
ds
.
network
.
SetUpPod
(
config
.
GetMetadata
()
.
Namespace
,
config
.
GetMetadata
()
.
Name
,
cID
,
config
.
Annotations
)
networkOptions
:=
make
(
map
[
string
]
string
)
if
dnsConfig
:=
config
.
GetDnsConfig
();
dnsConfig
!=
nil
{
// Build DNS options.
dnsOption
,
err
:=
json
.
Marshal
(
dnsConfig
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to marshal dns config for pod %q: %v"
,
config
.
Metadata
.
Name
,
err
)
}
networkOptions
[
"dns"
]
=
string
(
dnsOption
)
}
err
=
ds
.
network
.
SetUpPod
(
config
.
GetMetadata
()
.
Namespace
,
config
.
GetMetadata
()
.
Name
,
cID
,
config
.
Annotations
,
networkOptions
)
if
err
!=
nil
{
if
err
!=
nil
{
errList
:=
[]
error
{
fmt
.
Errorf
(
"failed to set up sandbox container %q network for pod %q: %v"
,
createResp
.
ID
,
config
.
Metadata
.
Name
,
err
)}
errList
:=
[]
error
{
fmt
.
Errorf
(
"failed to set up sandbox container %q network for pod %q: %v"
,
createResp
.
ID
,
config
.
Metadata
.
Name
,
err
)}
...
...
pkg/kubelet/dockershim/docker_service_test.go
View file @
946aff88
...
@@ -27,7 +27,6 @@ import (
...
@@ -27,7 +27,6 @@ import (
"github.com/golang/mock/gomock"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/util/clock"
"k8s.io/apimachinery/pkg/util/clock"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager"
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager"
...
...
pkg/kubelet/dockershim/network/cni/cni.go
View file @
946aff88
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
cni
package
cni
import
(
import
(
"encoding/json"
"errors"
"errors"
"fmt"
"fmt"
"sort"
"sort"
...
@@ -27,6 +28,7 @@ import (
...
@@ -27,6 +28,7 @@ import (
cnitypes
"github.com/containernetworking/cni/pkg/types"
cnitypes
"github.com/containernetworking/cni/pkg/types"
"github.com/golang/glog"
"github.com/golang/glog"
kubeletconfig
"k8s.io/kubernetes/pkg/kubelet/apis/config"
kubeletconfig
"k8s.io/kubernetes/pkg/kubelet/apis/config"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockershim/network"
"k8s.io/kubernetes/pkg/kubelet/dockershim/network"
"k8s.io/kubernetes/pkg/util/bandwidth"
"k8s.io/kubernetes/pkg/util/bandwidth"
...
@@ -89,6 +91,18 @@ type cniIpRange struct {
...
@@ -89,6 +91,18 @@ type cniIpRange struct {
Subnet
string
`json:"subnet"`
Subnet
string
`json:"subnet"`
}
}
// cniDNSConfig maps to the windows CNI dns Capability.
// see: https://github.com/containernetworking/cni/blob/master/CONVENTIONS.md
// Note that dns capability is only used for Windows containers.
type
cniDNSConfig
struct
{
// List of DNS servers of the cluster.
Servers
[]
string
`json:"servers,omitempty"`
// List of DNS search domains of the cluster.
Searches
[]
string
`json:"searches,omitempty"`
// List of DNS options.
Options
[]
string
`json:"options,omitempty"`
}
func
SplitDirs
(
dirs
string
)
[]
string
{
func
SplitDirs
(
dirs
string
)
[]
string
{
// Use comma rather than colon to work better with Windows too
// Use comma rather than colon to work better with Windows too
return
strings
.
Split
(
dirs
,
","
)
return
strings
.
Split
(
dirs
,
","
)
...
@@ -256,7 +270,7 @@ func (plugin *cniNetworkPlugin) Status() error {
...
@@ -256,7 +270,7 @@ func (plugin *cniNetworkPlugin) Status() error {
return
plugin
.
checkInitialized
()
return
plugin
.
checkInitialized
()
}
}
func
(
plugin
*
cniNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
,
annotations
map
[
string
]
string
)
error
{
func
(
plugin
*
cniNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
,
annotations
,
options
map
[
string
]
string
)
error
{
if
err
:=
plugin
.
checkInitialized
();
err
!=
nil
{
if
err
:=
plugin
.
checkInitialized
();
err
!=
nil
{
return
err
return
err
}
}
...
@@ -267,12 +281,12 @@ func (plugin *cniNetworkPlugin) SetUpPod(namespace string, name string, id kubec
...
@@ -267,12 +281,12 @@ func (plugin *cniNetworkPlugin) SetUpPod(namespace string, name string, id kubec
// Windows doesn't have loNetwork. It comes only with Linux
// Windows doesn't have loNetwork. It comes only with Linux
if
plugin
.
loNetwork
!=
nil
{
if
plugin
.
loNetwork
!=
nil
{
if
_
,
err
=
plugin
.
addToNetwork
(
plugin
.
loNetwork
,
name
,
namespace
,
id
,
netnsPath
,
annotations
);
err
!=
nil
{
if
_
,
err
=
plugin
.
addToNetwork
(
plugin
.
loNetwork
,
name
,
namespace
,
id
,
netnsPath
,
annotations
,
options
);
err
!=
nil
{
return
err
return
err
}
}
}
}
_
,
err
=
plugin
.
addToNetwork
(
plugin
.
getDefaultNetwork
(),
name
,
namespace
,
id
,
netnsPath
,
annotations
)
_
,
err
=
plugin
.
addToNetwork
(
plugin
.
getDefaultNetwork
(),
name
,
namespace
,
id
,
netnsPath
,
annotations
,
options
)
return
err
return
err
}
}
...
@@ -294,8 +308,8 @@ func podDesc(namespace, name string, id kubecontainer.ContainerID) string {
...
@@ -294,8 +308,8 @@ func podDesc(namespace, name string, id kubecontainer.ContainerID) string {
return
fmt
.
Sprintf
(
"%s_%s/%s"
,
namespace
,
name
,
id
.
ID
)
return
fmt
.
Sprintf
(
"%s_%s/%s"
,
namespace
,
name
,
id
.
ID
)
}
}
func
(
plugin
*
cniNetworkPlugin
)
addToNetwork
(
network
*
cniNetwork
,
podName
string
,
podNamespace
string
,
podSandboxID
kubecontainer
.
ContainerID
,
podNetnsPath
string
,
annotations
map
[
string
]
string
)
(
cnitypes
.
Result
,
error
)
{
func
(
plugin
*
cniNetworkPlugin
)
addToNetwork
(
network
*
cniNetwork
,
podName
string
,
podNamespace
string
,
podSandboxID
kubecontainer
.
ContainerID
,
podNetnsPath
string
,
annotations
,
options
map
[
string
]
string
)
(
cnitypes
.
Result
,
error
)
{
rt
,
err
:=
plugin
.
buildCNIRuntimeConf
(
podName
,
podNamespace
,
podSandboxID
,
podNetnsPath
,
annotations
)
rt
,
err
:=
plugin
.
buildCNIRuntimeConf
(
podName
,
podNamespace
,
podSandboxID
,
podNetnsPath
,
annotations
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error adding network when building cni runtime conf: %v"
,
err
)
glog
.
Errorf
(
"Error adding network when building cni runtime conf: %v"
,
err
)
return
nil
,
err
return
nil
,
err
...
@@ -314,7 +328,7 @@ func (plugin *cniNetworkPlugin) addToNetwork(network *cniNetwork, podName string
...
@@ -314,7 +328,7 @@ func (plugin *cniNetworkPlugin) addToNetwork(network *cniNetwork, podName string
}
}
func
(
plugin
*
cniNetworkPlugin
)
deleteFromNetwork
(
network
*
cniNetwork
,
podName
string
,
podNamespace
string
,
podSandboxID
kubecontainer
.
ContainerID
,
podNetnsPath
string
,
annotations
map
[
string
]
string
)
error
{
func
(
plugin
*
cniNetworkPlugin
)
deleteFromNetwork
(
network
*
cniNetwork
,
podName
string
,
podNamespace
string
,
podSandboxID
kubecontainer
.
ContainerID
,
podNetnsPath
string
,
annotations
map
[
string
]
string
)
error
{
rt
,
err
:=
plugin
.
buildCNIRuntimeConf
(
podName
,
podNamespace
,
podSandboxID
,
podNetnsPath
,
annotations
)
rt
,
err
:=
plugin
.
buildCNIRuntimeConf
(
podName
,
podNamespace
,
podSandboxID
,
podNetnsPath
,
annotations
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error deleting network when building cni runtime conf: %v"
,
err
)
glog
.
Errorf
(
"Error deleting network when building cni runtime conf: %v"
,
err
)
return
err
return
err
...
@@ -334,7 +348,7 @@ func (plugin *cniNetworkPlugin) deleteFromNetwork(network *cniNetwork, podName s
...
@@ -334,7 +348,7 @@ func (plugin *cniNetworkPlugin) deleteFromNetwork(network *cniNetwork, podName s
return
nil
return
nil
}
}
func
(
plugin
*
cniNetworkPlugin
)
buildCNIRuntimeConf
(
podName
string
,
podNs
string
,
podSandboxID
kubecontainer
.
ContainerID
,
podNetnsPath
string
,
annotations
map
[
string
]
string
)
(
*
libcni
.
RuntimeConf
,
error
)
{
func
(
plugin
*
cniNetworkPlugin
)
buildCNIRuntimeConf
(
podName
string
,
podNs
string
,
podSandboxID
kubecontainer
.
ContainerID
,
podNetnsPath
string
,
annotations
,
options
map
[
string
]
string
)
(
*
libcni
.
RuntimeConf
,
error
)
{
rt
:=
&
libcni
.
RuntimeConf
{
rt
:=
&
libcni
.
RuntimeConf
{
ContainerID
:
podSandboxID
.
ID
,
ContainerID
:
podSandboxID
.
ID
,
NetNS
:
podNetnsPath
,
NetNS
:
podNetnsPath
,
...
@@ -389,5 +403,17 @@ func (plugin *cniNetworkPlugin) buildCNIRuntimeConf(podName string, podNs string
...
@@ -389,5 +403,17 @@ func (plugin *cniNetworkPlugin) buildCNIRuntimeConf(podName string, podNs string
// Set the PodCIDR
// Set the PodCIDR
rt
.
CapabilityArgs
[
"ipRanges"
]
=
[][]
cniIpRange
{{{
Subnet
:
plugin
.
podCidr
}}}
rt
.
CapabilityArgs
[
"ipRanges"
]
=
[][]
cniIpRange
{{{
Subnet
:
plugin
.
podCidr
}}}
// Set dns capability args.
if
dnsOptions
,
ok
:=
options
[
"dns"
];
ok
{
dnsConfig
:=
runtimeapi
.
DNSConfig
{}
err
:=
json
.
Unmarshal
([]
byte
(
dnsOptions
),
&
dnsConfig
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to unmarshal dns config %q: %v"
,
dnsOptions
,
err
)
}
if
dnsParam
:=
buildDNSCapabilities
(
&
dnsConfig
);
dnsParam
!=
nil
{
rt
.
CapabilityArgs
[
"dns"
]
=
*
dnsParam
}
}
return
rt
,
nil
return
rt
,
nil
}
}
pkg/kubelet/dockershim/network/cni/cni_others.go
View file @
946aff88
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"fmt"
"fmt"
"github.com/containernetworking/cni/libcni"
"github.com/containernetworking/cni/libcni"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockershim/network"
"k8s.io/kubernetes/pkg/kubelet/dockershim/network"
)
)
...
@@ -75,3 +76,8 @@ func (plugin *cniNetworkPlugin) GetPodNetworkStatus(namespace string, name strin
...
@@ -75,3 +76,8 @@ func (plugin *cniNetworkPlugin) GetPodNetworkStatus(namespace string, name strin
return
&
network
.
PodNetworkStatus
{
IP
:
ip
},
nil
return
&
network
.
PodNetworkStatus
{
IP
:
ip
},
nil
}
}
// buildDNSCapabilities builds cniDNSConfig from runtimeapi.DNSConfig.
func
buildDNSCapabilities
(
dnsConfig
*
runtimeapi
.
DNSConfig
)
*
cniDNSConfig
{
return
nil
}
pkg/kubelet/dockershim/network/cni/cni_test.go
View file @
946aff88
...
@@ -254,7 +254,7 @@ func TestCNIPlugin(t *testing.T) {
...
@@ -254,7 +254,7 @@ func TestCNIPlugin(t *testing.T) {
bandwidthAnnotation
[
"kubernetes.io/egress-bandwidth"
]
=
"1M"
bandwidthAnnotation
[
"kubernetes.io/egress-bandwidth"
]
=
"1M"
// Set up the pod
// Set up the pod
err
=
plug
.
SetUpPod
(
"podNamespace"
,
"podName"
,
containerID
,
bandwidthAnnotation
)
err
=
plug
.
SetUpPod
(
"podNamespace"
,
"podName"
,
containerID
,
bandwidthAnnotation
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Expected nil: %v"
,
err
)
t
.
Errorf
(
"Expected nil: %v"
,
err
)
}
}
...
...
pkg/kubelet/dockershim/network/cni/cni_windows.go
View file @
946aff88
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
cniTypes020
"github.com/containernetworking/cni/pkg/types/020"
cniTypes020
"github.com/containernetworking/cni/pkg/types/020"
"github.com/golang/glog"
"github.com/golang/glog"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockershim/network"
"k8s.io/kubernetes/pkg/kubelet/dockershim/network"
)
)
...
@@ -42,7 +43,7 @@ func (plugin *cniNetworkPlugin) GetPodNetworkStatus(namespace string, name strin
...
@@ -42,7 +43,7 @@ func (plugin *cniNetworkPlugin) GetPodNetworkStatus(namespace string, name strin
return
nil
,
fmt
.
Errorf
(
"CNI failed to retrieve network namespace path: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"CNI failed to retrieve network namespace path: %v"
,
err
)
}
}
result
,
err
:=
plugin
.
addToNetwork
(
plugin
.
getDefaultNetwork
(),
name
,
namespace
,
id
,
netnsPath
,
nil
)
result
,
err
:=
plugin
.
addToNetwork
(
plugin
.
getDefaultNetwork
(),
name
,
namespace
,
id
,
netnsPath
,
nil
,
nil
)
glog
.
V
(
5
)
.
Infof
(
"GetPodNetworkStatus result %+v"
,
result
)
glog
.
V
(
5
)
.
Infof
(
"GetPodNetworkStatus result %+v"
,
result
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -59,3 +60,16 @@ func (plugin *cniNetworkPlugin) GetPodNetworkStatus(namespace string, name strin
...
@@ -59,3 +60,16 @@ func (plugin *cniNetworkPlugin) GetPodNetworkStatus(namespace string, name strin
}
}
return
&
network
.
PodNetworkStatus
{
IP
:
result020
.
IP4
.
IP
.
IP
},
nil
return
&
network
.
PodNetworkStatus
{
IP
:
result020
.
IP4
.
IP
.
IP
},
nil
}
}
// buildDNSCapabilities builds cniDNSConfig from runtimeapi.DNSConfig.
func
buildDNSCapabilities
(
dnsConfig
*
runtimeapi
.
DNSConfig
)
*
cniDNSConfig
{
if
dnsConfig
!=
nil
{
return
&
cniDNSConfig
{
Servers
:
dnsConfig
.
Servers
,
Searches
:
dnsConfig
.
Searches
,
Options
:
dnsConfig
.
Options
,
}
}
return
nil
}
pkg/kubelet/dockershim/network/kubenet/kubenet_linux.go
View file @
946aff88
...
@@ -379,7 +379,7 @@ func (plugin *kubenetNetworkPlugin) setup(namespace string, name string, id kube
...
@@ -379,7 +379,7 @@ func (plugin *kubenetNetworkPlugin) setup(namespace string, name string, id kube
return
nil
return
nil
}
}
func
(
plugin
*
kubenetNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
,
annotations
map
[
string
]
string
)
error
{
func
(
plugin
*
kubenetNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
,
annotations
,
options
map
[
string
]
string
)
error
{
plugin
.
mu
.
Lock
()
plugin
.
mu
.
Lock
()
defer
plugin
.
mu
.
Unlock
()
defer
plugin
.
mu
.
Unlock
()
...
...
pkg/kubelet/dockershim/network/kubenet/kubenet_unsupported.go
View file @
946aff88
...
@@ -42,7 +42,7 @@ func (plugin *kubenetNetworkPlugin) Name() string {
...
@@ -42,7 +42,7 @@ func (plugin *kubenetNetworkPlugin) Name() string {
return
"kubenet"
return
"kubenet"
}
}
func
(
plugin
*
kubenetNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
,
annotations
map
[
string
]
string
)
error
{
func
(
plugin
*
kubenetNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
,
annotations
,
options
map
[
string
]
string
)
error
{
return
fmt
.
Errorf
(
"Kubenet is not supported in this build"
)
return
fmt
.
Errorf
(
"Kubenet is not supported in this build"
)
}
}
...
...
pkg/kubelet/dockershim/network/plugins.go
View file @
946aff88
...
@@ -63,7 +63,7 @@ type NetworkPlugin interface {
...
@@ -63,7 +63,7 @@ type NetworkPlugin interface {
// SetUpPod is the method called after the infra container of
// SetUpPod is the method called after the infra container of
// the pod has been created but before the other containers of the
// the pod has been created but before the other containers of the
// pod are launched.
// pod are launched.
SetUpPod
(
namespace
string
,
name
string
,
podSandboxID
kubecontainer
.
ContainerID
,
annotations
map
[
string
]
string
)
error
SetUpPod
(
namespace
string
,
name
string
,
podSandboxID
kubecontainer
.
ContainerID
,
annotations
,
options
map
[
string
]
string
)
error
// TearDownPod is the method called before a pod's infra container will be deleted
// TearDownPod is the method called before a pod's infra container will be deleted
TearDownPod
(
namespace
string
,
name
string
,
podSandboxID
kubecontainer
.
ContainerID
)
error
TearDownPod
(
namespace
string
,
name
string
,
podSandboxID
kubecontainer
.
ContainerID
)
error
...
@@ -207,7 +207,7 @@ func (plugin *NoopNetworkPlugin) Capabilities() utilsets.Int {
...
@@ -207,7 +207,7 @@ func (plugin *NoopNetworkPlugin) Capabilities() utilsets.Int {
return
utilsets
.
NewInt
()
return
utilsets
.
NewInt
()
}
}
func
(
plugin
*
NoopNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
,
annotations
map
[
string
]
string
)
error
{
func
(
plugin
*
NoopNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
,
annotations
,
options
map
[
string
]
string
)
error
{
return
nil
return
nil
}
}
...
@@ -368,14 +368,14 @@ func (pm *PluginManager) GetPodNetworkStatus(podNamespace, podName string, id ku
...
@@ -368,14 +368,14 @@ func (pm *PluginManager) GetPodNetworkStatus(podNamespace, podName string, id ku
return
netStatus
,
nil
return
netStatus
,
nil
}
}
func
(
pm
*
PluginManager
)
SetUpPod
(
podNamespace
,
podName
string
,
id
kubecontainer
.
ContainerID
,
annotations
map
[
string
]
string
)
error
{
func
(
pm
*
PluginManager
)
SetUpPod
(
podNamespace
,
podName
string
,
id
kubecontainer
.
ContainerID
,
annotations
,
options
map
[
string
]
string
)
error
{
defer
recordOperation
(
"set_up_pod"
,
time
.
Now
())
defer
recordOperation
(
"set_up_pod"
,
time
.
Now
())
fullPodName
:=
kubecontainer
.
BuildPodFullName
(
podName
,
podNamespace
)
fullPodName
:=
kubecontainer
.
BuildPodFullName
(
podName
,
podNamespace
)
pm
.
podLock
(
fullPodName
)
.
Lock
()
pm
.
podLock
(
fullPodName
)
.
Lock
()
defer
pm
.
podUnlock
(
fullPodName
)
defer
pm
.
podUnlock
(
fullPodName
)
glog
.
V
(
3
)
.
Infof
(
"Calling network plugin %s to set up pod %q"
,
pm
.
plugin
.
Name
(),
fullPodName
)
glog
.
V
(
3
)
.
Infof
(
"Calling network plugin %s to set up pod %q"
,
pm
.
plugin
.
Name
(),
fullPodName
)
if
err
:=
pm
.
plugin
.
SetUpPod
(
podNamespace
,
podName
,
id
,
annotations
);
err
!=
nil
{
if
err
:=
pm
.
plugin
.
SetUpPod
(
podNamespace
,
podName
,
id
,
annotations
,
options
);
err
!=
nil
{
return
fmt
.
Errorf
(
"NetworkPlugin %s failed to set up pod %q network: %v"
,
pm
.
plugin
.
Name
(),
fullPodName
,
err
)
return
fmt
.
Errorf
(
"NetworkPlugin %s failed to set up pod %q network: %v"
,
pm
.
plugin
.
Name
(),
fullPodName
,
err
)
}
}
...
...
pkg/kubelet/dockershim/network/testing/mock_network_plugin.go
View file @
946aff88
...
@@ -102,7 +102,7 @@ func (_mr *_MockNetworkPluginRecorder) Name() *gomock.Call {
...
@@ -102,7 +102,7 @@ func (_mr *_MockNetworkPluginRecorder) Name() *gomock.Call {
return
_mr
.
mock
.
ctrl
.
RecordCall
(
_mr
.
mock
,
"Name"
)
return
_mr
.
mock
.
ctrl
.
RecordCall
(
_mr
.
mock
,
"Name"
)
}
}
func
(
_m
*
MockNetworkPlugin
)
SetUpPod
(
_param0
string
,
_param1
string
,
_param2
container
.
ContainerID
,
annotations
map
[
string
]
string
)
error
{
func
(
_m
*
MockNetworkPlugin
)
SetUpPod
(
_param0
string
,
_param1
string
,
_param2
container
.
ContainerID
,
annotations
,
options
map
[
string
]
string
)
error
{
ret
:=
_m
.
ctrl
.
Call
(
_m
,
"SetUpPod"
,
_param0
,
_param1
,
_param2
)
ret
:=
_m
.
ctrl
.
Call
(
_m
,
"SetUpPod"
,
_param0
,
_param1
,
_param2
)
ret0
,
_
:=
ret
[
0
]
.
(
error
)
ret0
,
_
:=
ret
[
0
]
.
(
error
)
return
ret0
return
ret0
...
...
pkg/kubelet/dockershim/network/testing/plugins_test.go
View file @
946aff88
...
@@ -108,7 +108,7 @@ func TestPluginManager(t *testing.T) {
...
@@ -108,7 +108,7 @@ func TestPluginManager(t *testing.T) {
// concurrently.
// concurrently.
allCreatedWg
.
Wait
()
allCreatedWg
.
Wait
()
if
err
:=
pm
.
SetUpPod
(
""
,
name
,
id
,
nil
);
err
!=
nil
{
if
err
:=
pm
.
SetUpPod
(
""
,
name
,
id
,
nil
,
nil
);
err
!=
nil
{
t
.
Errorf
(
"Failed to set up pod %q: %v"
,
name
,
err
)
t
.
Errorf
(
"Failed to set up pod %q: %v"
,
name
,
err
)
return
return
}
}
...
@@ -159,7 +159,7 @@ func (p *hookableFakeNetworkPlugin) Capabilities() utilsets.Int {
...
@@ -159,7 +159,7 @@ func (p *hookableFakeNetworkPlugin) Capabilities() utilsets.Int {
return
utilsets
.
NewInt
()
return
utilsets
.
NewInt
()
}
}
func
(
p
*
hookableFakeNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
,
annotations
map
[
string
]
string
)
error
{
func
(
p
*
hookableFakeNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
,
annotations
,
options
map
[
string
]
string
)
error
{
if
p
.
setupHook
!=
nil
{
if
p
.
setupHook
!=
nil
{
p
.
setupHook
(
namespace
,
name
,
id
)
p
.
setupHook
(
namespace
,
name
,
id
)
}
}
...
@@ -210,7 +210,7 @@ func TestMultiPodParallelNetworkOps(t *testing.T) {
...
@@ -210,7 +210,7 @@ func TestMultiPodParallelNetworkOps(t *testing.T) {
// Setup will block on the runner pod completing. If network
// Setup will block on the runner pod completing. If network
// operations locking isn't correct (eg pod network operations
// operations locking isn't correct (eg pod network operations
// block other pods) setUpPod() will never return.
// block other pods) setUpPod() will never return.
if
err
:=
pm
.
SetUpPod
(
""
,
podName
,
containerID
,
nil
);
err
!=
nil
{
if
err
:=
pm
.
SetUpPod
(
""
,
podName
,
containerID
,
nil
,
nil
);
err
!=
nil
{
t
.
Errorf
(
"Failed to set up waiter pod: %v"
,
err
)
t
.
Errorf
(
"Failed to set up waiter pod: %v"
,
err
)
return
return
}
}
...
@@ -230,7 +230,7 @@ func TestMultiPodParallelNetworkOps(t *testing.T) {
...
@@ -230,7 +230,7 @@ func TestMultiPodParallelNetworkOps(t *testing.T) {
podName
:=
"runner"
podName
:=
"runner"
containerID
:=
kubecontainer
.
ContainerID
{
ID
:
podName
}
containerID
:=
kubecontainer
.
ContainerID
{
ID
:
podName
}
if
err
:=
pm
.
SetUpPod
(
""
,
podName
,
containerID
,
nil
);
err
!=
nil
{
if
err
:=
pm
.
SetUpPod
(
""
,
podName
,
containerID
,
nil
,
nil
);
err
!=
nil
{
t
.
Errorf
(
"Failed to set up runner pod: %v"
,
err
)
t
.
Errorf
(
"Failed to set up runner pod: %v"
,
err
)
return
return
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment