Commit 9b210531 authored by jhadvig's avatar jhadvig

ListContainer filter

parent 8469a343
...@@ -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
} }
......
...@@ -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)
} }
......
...@@ -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
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment