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
1a92e218
Commit
1a92e218
authored
Feb 06, 2019
by
Lantao Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused function from the legacy runtime interface.
Signed-off-by:
Lantao Liu
<
lantaol@google.com
>
parent
152b09ac
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
11 additions
and
164 deletions
+11
-164
runtime.go
pkg/kubelet/container/runtime.go
+0
-11
fake_runtime.go
pkg/kubelet/container/testing/fake_runtime.go
+0
-25
runtime_mock.go
pkg/kubelet/container/testing/runtime_mock.go
+0
-10
cni_test.go
pkg/kubelet/dockershim/network/cni/cni_test.go
+10
-9
kubenet_linux_test.go
pkg/kubelet/dockershim/network/kubenet/kubenet_linux_test.go
+0
-1
BUILD
pkg/kubelet/dockershim/network/testing/BUILD
+0
-1
fake_host.go
pkg/kubelet/dockershim/network/testing/fake_host.go
+1
-8
kuberuntime_manager.go
pkg/kubelet/kuberuntime/kuberuntime_manager.go
+0
-20
kuberuntime_manager_test.go
pkg/kubelet/kuberuntime/kuberuntime_manager_test.go
+0
-79
No files found.
pkg/kubelet/container/runtime.go
View file @
1a92e218
...
@@ -98,17 +98,6 @@ type Runtime interface {
...
@@ -98,17 +98,6 @@ type Runtime interface {
// GetPodStatus retrieves the status of the pod, including the
// GetPodStatus retrieves the status of the pod, including the
// information of all containers in the pod that are visible in Runtime.
// information of all containers in the pod that are visible in Runtime.
GetPodStatus
(
uid
types
.
UID
,
name
,
namespace
string
)
(
*
PodStatus
,
error
)
GetPodStatus
(
uid
types
.
UID
,
name
,
namespace
string
)
(
*
PodStatus
,
error
)
// Returns the filesystem path of the pod's network namespace; if the
// runtime does not handle namespace creation itself, or cannot return
// the network namespace path, it should return an error.
// TODO: Change ContainerID to a Pod ID since the namespace is shared
// by all containers in the pod.
GetNetNS
(
containerID
ContainerID
)
(
string
,
error
)
// Returns the container ID that represents the Pod, as passed to network
// plugins. For example, if the runtime uses an infra container, returns
// the infra container's ContainerID.
// TODO: Change ContainerID to a Pod ID, see GetNetNS()
GetPodContainerID
(
*
Pod
)
(
ContainerID
,
error
)
// TODO(vmarmol): Unify pod and containerID args.
// TODO(vmarmol): Unify pod and containerID args.
// GetContainerLogs returns logs of a specific container. By
// GetContainerLogs returns logs of a specific container. By
// default, it returns a snapshot of the container log. Set 'follow' to true to
// default, it returns a snapshot of the container log. Set 'follow' to true to
...
...
pkg/kubelet/container/testing/fake_runtime.go
View file @
1a92e218
...
@@ -345,31 +345,6 @@ func (f *FakeRuntime) RemoveImage(image ImageSpec) error {
...
@@ -345,31 +345,6 @@ func (f *FakeRuntime) RemoveImage(image ImageSpec) error {
return
f
.
Err
return
f
.
Err
}
}
func
(
f
*
FakeRuntime
)
GetNetNS
(
containerID
ContainerID
)
(
string
,
error
)
{
f
.
Lock
()
defer
f
.
Unlock
()
f
.
CalledFunctions
=
append
(
f
.
CalledFunctions
,
"GetNetNS"
)
for
_
,
fp
:=
range
f
.
AllPodList
{
for
_
,
c
:=
range
fp
.
Pod
.
Containers
{
if
c
.
ID
==
containerID
{
return
fp
.
NetnsPath
,
nil
}
}
}
return
""
,
f
.
Err
}
func
(
f
*
FakeRuntime
)
GetPodContainerID
(
pod
*
Pod
)
(
ContainerID
,
error
)
{
f
.
Lock
()
defer
f
.
Unlock
()
f
.
CalledFunctions
=
append
(
f
.
CalledFunctions
,
"GetPodContainerID"
)
return
ContainerID
{},
f
.
Err
}
func
(
f
*
FakeRuntime
)
GarbageCollect
(
gcPolicy
ContainerGCPolicy
,
ready
bool
,
evictNonDeletedPods
bool
)
error
{
func
(
f
*
FakeRuntime
)
GarbageCollect
(
gcPolicy
ContainerGCPolicy
,
ready
bool
,
evictNonDeletedPods
bool
)
error
{
f
.
Lock
()
f
.
Lock
()
defer
f
.
Unlock
()
defer
f
.
Unlock
()
...
...
pkg/kubelet/container/testing/runtime_mock.go
View file @
1a92e218
...
@@ -132,16 +132,6 @@ func (r *Mock) PortForward(pod *Pod, port uint16, stream io.ReadWriteCloser) err
...
@@ -132,16 +132,6 @@ func (r *Mock) PortForward(pod *Pod, port uint16, stream io.ReadWriteCloser) err
return
args
.
Error
(
0
)
return
args
.
Error
(
0
)
}
}
func
(
r
*
Mock
)
GetNetNS
(
containerID
ContainerID
)
(
string
,
error
)
{
args
:=
r
.
Called
(
containerID
)
return
""
,
args
.
Error
(
0
)
}
func
(
r
*
Mock
)
GetPodContainerID
(
pod
*
Pod
)
(
ContainerID
,
error
)
{
args
:=
r
.
Called
(
pod
)
return
ContainerID
{},
args
.
Error
(
0
)
}
func
(
r
*
Mock
)
GarbageCollect
(
gcPolicy
ContainerGCPolicy
,
ready
bool
,
evictNonDeletedPods
bool
)
error
{
func
(
r
*
Mock
)
GarbageCollect
(
gcPolicy
ContainerGCPolicy
,
ready
bool
,
evictNonDeletedPods
bool
)
error
{
args
:=
r
.
Called
(
gcPolicy
,
ready
,
evictNonDeletedPods
)
args
:=
r
.
Called
(
gcPolicy
,
ready
,
evictNonDeletedPods
)
return
args
.
Error
(
0
)
return
args
.
Error
(
0
)
...
...
pkg/kubelet/dockershim/network/cni/cni_test.go
View file @
1a92e218
...
@@ -121,16 +121,14 @@ func tearDownPlugin(tmpDir string) {
...
@@ -121,16 +121,14 @@ func tearDownPlugin(tmpDir string) {
type
fakeNetworkHost
struct
{
type
fakeNetworkHost
struct
{
networktest
.
FakePortMappingGetter
networktest
.
FakePortMappingGetter
kubeClient
clientset
.
Interface
kubeClient
clientset
.
Interface
runtime
kubecontainer
.
Runtime
pods
[]
*
containertest
.
FakePod
}
}
func
NewFakeHost
(
kubeClient
clientset
.
Interface
,
pods
[]
*
containertest
.
FakePod
,
ports
map
[
string
][]
*
hostport
.
PortMapping
)
*
fakeNetworkHost
{
func
NewFakeHost
(
kubeClient
clientset
.
Interface
,
pods
[]
*
containertest
.
FakePod
,
ports
map
[
string
][]
*
hostport
.
PortMapping
)
*
fakeNetworkHost
{
host
:=
&
fakeNetworkHost
{
host
:=
&
fakeNetworkHost
{
networktest
.
FakePortMappingGetter
{
PortMaps
:
ports
},
networktest
.
FakePortMappingGetter
{
PortMaps
:
ports
},
kubeClient
,
kubeClient
,
&
containertest
.
FakeRuntime
{
pods
,
AllPodList
:
pods
,
},
}
}
return
host
return
host
}
}
...
@@ -143,12 +141,15 @@ func (fnh *fakeNetworkHost) GetKubeClient() clientset.Interface {
...
@@ -143,12 +141,15 @@ func (fnh *fakeNetworkHost) GetKubeClient() clientset.Interface {
return
fnh
.
kubeClient
return
fnh
.
kubeClient
}
}
func
(
fnh
*
fakeNetworkHost
)
GetRuntime
()
kubecontainer
.
Runtime
{
return
fnh
.
runtime
}
func
(
fnh
*
fakeNetworkHost
)
GetNetNS
(
containerID
string
)
(
string
,
error
)
{
func
(
fnh
*
fakeNetworkHost
)
GetNetNS
(
containerID
string
)
(
string
,
error
)
{
return
fnh
.
GetRuntime
()
.
GetNetNS
(
kubecontainer
.
ContainerID
{
Type
:
"test"
,
ID
:
containerID
})
for
_
,
fp
:=
range
fnh
.
pods
{
for
_
,
c
:=
range
fp
.
Pod
.
Containers
{
if
c
.
ID
.
ID
==
containerID
{
return
fp
.
NetnsPath
,
nil
}
}
}
return
""
,
fmt
.
Errorf
(
"container %q not found"
,
containerID
)
}
}
func
(
fnh
*
fakeNetworkHost
)
SupportsLegacyFeatures
()
bool
{
func
(
fnh
*
fakeNetworkHost
)
SupportsLegacyFeatures
()
bool
{
...
...
pkg/kubelet/dockershim/network/kubenet/kubenet_linux_test.go
View file @
1a92e218
...
@@ -221,7 +221,6 @@ func TestTearDownWithoutRuntime(t *testing.T) {
...
@@ -221,7 +221,6 @@ func TestTearDownWithoutRuntime(t *testing.T) {
for
_
,
tc
:=
range
testCases
{
for
_
,
tc
:=
range
testCases
{
fhost
:=
nettest
.
NewFakeHost
(
nil
)
fhost
:=
nettest
.
NewFakeHost
(
nil
)
fhost
.
Legacy
=
false
fhost
.
Legacy
=
false
fhost
.
Runtime
=
nil
mockcni
:=
&
mock_cni
.
MockCNI
{}
mockcni
:=
&
mock_cni
.
MockCNI
{}
fexec
:=
&
fakeexec
.
FakeExec
{
fexec
:=
&
fakeexec
.
FakeExec
{
...
...
pkg/kubelet/dockershim/network/testing/BUILD
View file @
1a92e218
...
@@ -16,7 +16,6 @@ go_library(
...
@@ -16,7 +16,6 @@ go_library(
deps = [
deps = [
"//pkg/kubelet/apis/config:go_default_library",
"//pkg/kubelet/apis/config:go_default_library",
"//pkg/kubelet/container:go_default_library",
"//pkg/kubelet/container:go_default_library",
"//pkg/kubelet/container/testing:go_default_library",
"//pkg/kubelet/dockershim/network:go_default_library",
"//pkg/kubelet/dockershim/network:go_default_library",
"//pkg/kubelet/dockershim/network/hostport:go_default_library",
"//pkg/kubelet/dockershim/network/hostport:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
...
...
pkg/kubelet/dockershim/network/testing/fake_host.go
View file @
1a92e218
...
@@ -22,8 +22,6 @@ package testing
...
@@ -22,8 +22,6 @@ package testing
import
(
import
(
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
clientset
"k8s.io/client-go/kubernetes"
clientset
"k8s.io/client-go/kubernetes"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
containertest
"k8s.io/kubernetes/pkg/kubelet/container/testing"
"k8s.io/kubernetes/pkg/kubelet/dockershim/network/hostport"
"k8s.io/kubernetes/pkg/kubelet/dockershim/network/hostport"
)
)
...
@@ -32,11 +30,10 @@ type fakeNetworkHost struct {
...
@@ -32,11 +30,10 @@ type fakeNetworkHost struct {
FakePortMappingGetter
FakePortMappingGetter
kubeClient
clientset
.
Interface
kubeClient
clientset
.
Interface
Legacy
bool
Legacy
bool
Runtime
*
containertest
.
FakeRuntime
}
}
func
NewFakeHost
(
kubeClient
clientset
.
Interface
)
*
fakeNetworkHost
{
func
NewFakeHost
(
kubeClient
clientset
.
Interface
)
*
fakeNetworkHost
{
host
:=
&
fakeNetworkHost
{
kubeClient
:
kubeClient
,
Legacy
:
true
,
Runtime
:
&
containertest
.
FakeRuntime
{}
}
host
:=
&
fakeNetworkHost
{
kubeClient
:
kubeClient
,
Legacy
:
true
}
return
host
return
host
}
}
...
@@ -48,10 +45,6 @@ func (fnh *fakeNetworkHost) GetKubeClient() clientset.Interface {
...
@@ -48,10 +45,6 @@ func (fnh *fakeNetworkHost) GetKubeClient() clientset.Interface {
return
nil
return
nil
}
}
func
(
nh
*
fakeNetworkHost
)
GetRuntime
()
kubecontainer
.
Runtime
{
return
nh
.
Runtime
}
func
(
nh
*
fakeNetworkHost
)
SupportsLegacyFeatures
()
bool
{
func
(
nh
*
fakeNetworkHost
)
SupportsLegacyFeatures
()
bool
{
return
nh
.
Legacy
return
nh
.
Legacy
}
}
...
...
pkg/kubelet/kuberuntime/kuberuntime_manager.go
View file @
1a92e218
...
@@ -914,31 +914,11 @@ func (m *kubeGenericRuntimeManager) GetPodStatus(uid kubetypes.UID, name, namesp
...
@@ -914,31 +914,11 @@ func (m *kubeGenericRuntimeManager) GetPodStatus(uid kubetypes.UID, name, namesp
},
nil
},
nil
}
}
// Returns the filesystem path of the pod's network namespace.
//
// For CRI, container network is handled by the runtime completely and this
// function should never be called.
func
(
m
*
kubeGenericRuntimeManager
)
GetNetNS
(
_
kubecontainer
.
ContainerID
)
(
string
,
error
)
{
return
""
,
fmt
.
Errorf
(
"not supported"
)
}
// GarbageCollect removes dead containers using the specified container gc policy.
// GarbageCollect removes dead containers using the specified container gc policy.
func
(
m
*
kubeGenericRuntimeManager
)
GarbageCollect
(
gcPolicy
kubecontainer
.
ContainerGCPolicy
,
allSourcesReady
bool
,
evictNonDeletedPods
bool
)
error
{
func
(
m
*
kubeGenericRuntimeManager
)
GarbageCollect
(
gcPolicy
kubecontainer
.
ContainerGCPolicy
,
allSourcesReady
bool
,
evictNonDeletedPods
bool
)
error
{
return
m
.
containerGC
.
GarbageCollect
(
gcPolicy
,
allSourcesReady
,
evictNonDeletedPods
)
return
m
.
containerGC
.
GarbageCollect
(
gcPolicy
,
allSourcesReady
,
evictNonDeletedPods
)
}
}
// GetPodContainerID gets pod sandbox ID
func
(
m
*
kubeGenericRuntimeManager
)
GetPodContainerID
(
pod
*
kubecontainer
.
Pod
)
(
kubecontainer
.
ContainerID
,
error
)
{
formattedPod
:=
kubecontainer
.
FormatPod
(
pod
)
if
len
(
pod
.
Sandboxes
)
==
0
{
klog
.
Errorf
(
"No sandboxes are found for pod %q"
,
formattedPod
)
return
kubecontainer
.
ContainerID
{},
fmt
.
Errorf
(
"sandboxes for pod %q not found"
,
formattedPod
)
}
// return sandboxID of the first sandbox since it is the latest one
return
pod
.
Sandboxes
[
0
]
.
ID
,
nil
}
// UpdatePodCIDR is just a passthrough method to update the runtimeConfig of the shim
// UpdatePodCIDR is just a passthrough method to update the runtimeConfig of the shim
// with the podCIDR supplied by the kubelet.
// with the podCIDR supplied by the kubelet.
func
(
m
*
kubeGenericRuntimeManager
)
UpdatePodCIDR
(
podCIDR
string
)
error
{
func
(
m
*
kubeGenericRuntimeManager
)
UpdatePodCIDR
(
podCIDR
string
)
error
{
...
...
pkg/kubelet/kuberuntime/kuberuntime_manager_test.go
View file @
1a92e218
...
@@ -388,85 +388,6 @@ func TestGetPods(t *testing.T) {
...
@@ -388,85 +388,6 @@ func TestGetPods(t *testing.T) {
}
}
}
}
func
TestGetPodContainerID
(
t
*
testing
.
T
)
{
fakeRuntime
,
_
,
m
,
err
:=
createTestRuntimeManager
()
assert
.
NoError
(
t
,
err
)
pod
:=
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
UID
:
"12345678"
,
Name
:
"foo"
,
Namespace
:
"new"
,
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
Name
:
"foo1"
,
Image
:
"busybox"
,
},
{
Name
:
"foo2"
,
Image
:
"busybox"
,
},
},
},
}
// Set fake sandbox and fake containers to fakeRuntime.
fakeSandbox
,
_
:=
makeAndSetFakePod
(
t
,
m
,
fakeRuntime
,
pod
)
// Convert fakeSandbox to kubecontainer.Container
sandbox
,
err
:=
m
.
sandboxToKubeContainer
(
&
runtimeapi
.
PodSandbox
{
Id
:
fakeSandbox
.
Id
,
Metadata
:
fakeSandbox
.
Metadata
,
State
:
fakeSandbox
.
State
,
CreatedAt
:
fakeSandbox
.
CreatedAt
,
Labels
:
fakeSandbox
.
Labels
,
})
assert
.
NoError
(
t
,
err
)
expectedPod
:=
&
kubecontainer
.
Pod
{
ID
:
pod
.
UID
,
Name
:
pod
.
Name
,
Namespace
:
pod
.
Namespace
,
Containers
:
[]
*
kubecontainer
.
Container
{},
Sandboxes
:
[]
*
kubecontainer
.
Container
{
sandbox
},
}
actual
,
err
:=
m
.
GetPodContainerID
(
expectedPod
)
assert
.
Equal
(
t
,
fakeSandbox
.
Id
,
actual
.
ID
)
}
func
TestGetNetNS
(
t
*
testing
.
T
)
{
fakeRuntime
,
_
,
m
,
err
:=
createTestRuntimeManager
()
assert
.
NoError
(
t
,
err
)
pod
:=
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
UID
:
"12345678"
,
Name
:
"foo"
,
Namespace
:
"new"
,
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
Name
:
"foo1"
,
Image
:
"busybox"
,
},
{
Name
:
"foo2"
,
Image
:
"busybox"
,
},
},
},
}
// Set fake sandbox and fake containers to fakeRuntime.
sandbox
,
_
:=
makeAndSetFakePod
(
t
,
m
,
fakeRuntime
,
pod
)
actual
,
err
:=
m
.
GetNetNS
(
kubecontainer
.
ContainerID
{
ID
:
sandbox
.
Id
})
assert
.
Equal
(
t
,
""
,
actual
)
assert
.
Equal
(
t
,
"not supported"
,
err
.
Error
())
}
func
TestKillPod
(
t
*
testing
.
T
)
{
func
TestKillPod
(
t
*
testing
.
T
)
{
fakeRuntime
,
_
,
m
,
err
:=
createTestRuntimeManager
()
fakeRuntime
,
_
,
m
,
err
:=
createTestRuntimeManager
()
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
...
...
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