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
9b210531
Commit
9b210531
authored
Sep 29, 2014
by
jhadvig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ListContainer filter
parent
8469a343
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
10 deletions
+11
-10
docker.go
pkg/kubelet/dockertools/docker.go
+4
-3
docker_test.go
pkg/kubelet/dockertools/docker_test.go
+1
-1
kubelet.go
pkg/kubelet/kubelet.go
+6
-6
No files found.
pkg/kubelet/dockertools/docker.go
View file @
9b210531
...
@@ -176,10 +176,11 @@ func (c DockerContainers) FindContainersByPodFullName(podFullName string) map[st
...
@@ -176,10 +176,11 @@ func (c DockerContainers) FindContainersByPodFullName(podFullName string) map[st
return
containers
return
containers
}
}
// GetKubeletDockerContainers returns a map of docker containers that we manage. The map key is the docker container ID
// GetKubeletDockerContainers takes client and boolean whether to list all container or just the running ones.
func
GetKubeletDockerContainers
(
client
DockerInterface
)
(
DockerContainers
,
error
)
{
// Returns a map of docker containers that we manage. The map key is the docker container ID
func
GetKubeletDockerContainers
(
client
DockerInterface
,
allContainers
bool
)
(
DockerContainers
,
error
)
{
result
:=
make
(
DockerContainers
)
result
:=
make
(
DockerContainers
)
containers
,
err
:=
client
.
ListContainers
(
docker
.
ListContainersOptions
{})
containers
,
err
:=
client
.
ListContainers
(
docker
.
ListContainersOptions
{
All
:
allContainers
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/kubelet/dockertools/docker_test.go
View file @
9b210531
...
@@ -62,7 +62,7 @@ func TestGetContainerID(t *testing.T) {
...
@@ -62,7 +62,7 @@ func TestGetContainerID(t *testing.T) {
ID
:
"foobar"
,
ID
:
"foobar"
,
}
}
dockerContainers
,
err
:=
GetKubeletDockerContainers
(
fakeDocker
)
dockerContainers
,
err
:=
GetKubeletDockerContainers
(
fakeDocker
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Expected no error, Got %#v"
,
err
)
t
.
Errorf
(
"Expected no error, Got %#v"
,
err
)
}
}
...
...
pkg/kubelet/kubelet.go
View file @
9b210531
...
@@ -448,7 +448,7 @@ func (kl *Kubelet) syncPod(pod *Pod, dockerContainers dockertools.DockerContaine
...
@@ -448,7 +448,7 @@ func (kl *Kubelet) syncPod(pod *Pod, dockerContainers dockertools.DockerContaine
netID
=
dockerNetworkID
netID
=
dockerNetworkID
if
count
>
0
{
if
count
>
0
{
// relist everything, otherwise we'll think we're ok
// relist everything, otherwise we'll think we're ok
dockerContainers
,
err
=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
)
dockerContainers
,
err
=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error listing containers %#v"
,
dockerContainers
)
glog
.
Errorf
(
"Error listing containers %#v"
,
dockerContainers
)
return
err
return
err
...
@@ -606,7 +606,7 @@ func (kl *Kubelet) SyncPods(pods []Pod) error {
...
@@ -606,7 +606,7 @@ func (kl *Kubelet) SyncPods(pods []Pod) error {
var
err
error
var
err
error
desiredContainers
:=
make
(
map
[
podContainer
]
empty
)
desiredContainers
:=
make
(
map
[
podContainer
]
empty
)
dockerContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
)
dockerContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error listing containers %#v"
,
dockerContainers
)
glog
.
Errorf
(
"Error listing containers %#v"
,
dockerContainers
)
return
err
return
err
...
@@ -634,7 +634,7 @@ func (kl *Kubelet) SyncPods(pods []Pod) error {
...
@@ -634,7 +634,7 @@ func (kl *Kubelet) SyncPods(pods []Pod) error {
}
}
// Kill any containers we don't need
// Kill any containers we don't need
existingContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
)
existingContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error listing containers: %v"
,
err
)
glog
.
Errorf
(
"Error listing containers: %v"
,
err
)
return
err
return
err
...
@@ -736,7 +736,7 @@ func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail stri
...
@@ -736,7 +736,7 @@ func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail stri
if
err
==
dockertools
.
ErrNoContainersInPod
{
if
err
==
dockertools
.
ErrNoContainersInPod
{
return
fmt
.
Errorf
(
"Pod not found (%s)
\n
"
,
podFullName
)
return
fmt
.
Errorf
(
"Pod not found (%s)
\n
"
,
podFullName
)
}
}
dockerContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
)
dockerContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -757,7 +757,7 @@ func (kl *Kubelet) GetContainerInfo(podFullName, uuid, containerName string, req
...
@@ -757,7 +757,7 @@ func (kl *Kubelet) GetContainerInfo(podFullName, uuid, containerName string, req
if
kl
.
cadvisorClient
==
nil
{
if
kl
.
cadvisorClient
==
nil
{
return
nil
,
nil
return
nil
,
nil
}
}
dockerContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
)
dockerContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -802,7 +802,7 @@ func (kl *Kubelet) RunInContainer(podFullName, uuid, container string, cmd []str
...
@@ -802,7 +802,7 @@ func (kl *Kubelet) RunInContainer(podFullName, uuid, container string, cmd []str
if
kl
.
runner
==
nil
{
if
kl
.
runner
==
nil
{
return
nil
,
fmt
.
Errorf
(
"no runner specified."
)
return
nil
,
fmt
.
Errorf
(
"no runner specified."
)
}
}
dockerContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
)
dockerContainers
,
err
:=
dockertools
.
GetKubeletDockerContainers
(
kl
.
dockerClient
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
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