mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
Remove unused type DockerContainers.
Type DockerContainers and function FindPodContainer() are never used. Remove them to simplify the docker runtime api.
This commit is contained in:
parent
5881c3c848
commit
b127901871
@ -32,7 +32,6 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/credentialprovider"
|
"k8s.io/kubernetes/pkg/credentialprovider"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/leaky"
|
"k8s.io/kubernetes/pkg/kubelet/leaky"
|
||||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
|
||||||
"k8s.io/kubernetes/pkg/types"
|
"k8s.io/kubernetes/pkg/types"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
utilerrors "k8s.io/kubernetes/pkg/util/errors"
|
utilerrors "k8s.io/kubernetes/pkg/util/errors"
|
||||||
@ -211,16 +210,12 @@ func (p throttledDockerPuller) IsImagePresent(name string) (bool, error) {
|
|||||||
return p.puller.IsImagePresent(name)
|
return p.puller.IsImagePresent(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO (random-liu) Almost never used, should we remove this?
|
// An internal helper function.
|
||||||
// DockerContainers is a map of containers
|
func findPodContainer(dockerContainers []*docker.APIContainers, podFullName string, uid types.UID, containerName string) (*docker.APIContainers, bool, uint64) {
|
||||||
type DockerContainers map[kubetypes.DockerID]*docker.APIContainers
|
for _, dockerContainer := range dockerContainers {
|
||||||
|
|
||||||
func (c DockerContainers) FindPodContainer(podFullName string, uid types.UID, containerName string) (*docker.APIContainers, bool, uint64) {
|
|
||||||
for _, dockerContainer := range c {
|
|
||||||
if len(dockerContainer.Names) == 0 {
|
if len(dockerContainer.Names) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// TODO(proppy): build the docker container name and do a map lookup instead?
|
|
||||||
dockerName, hash, err := ParseDockerName(dockerContainer.Names[0])
|
dockerName, hash, err := ParseDockerName(dockerContainer.Names[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
@ -348,10 +343,10 @@ func milliCPUToShares(milliCPU int64) int64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetKubeletDockerContainers lists all container or just the running ones.
|
// GetKubeletDockerContainers lists all container or just the running ones.
|
||||||
// Returns a map of docker containers that we manage, keyed by container ID.
|
// Returns a list of docker containers that we manage, keyed by container ID.
|
||||||
// TODO: Move this function with dockerCache to DockerManager.
|
// TODO: Move this function with dockerCache to DockerManager.
|
||||||
func GetKubeletDockerContainers(client DockerInterface, allContainers bool) (DockerContainers, error) {
|
func GetKubeletDockerContainers(client DockerInterface, allContainers bool) ([]*docker.APIContainers, error) {
|
||||||
result := make(DockerContainers)
|
result := []*docker.APIContainers{}
|
||||||
containers, err := client.ListContainers(docker.ListContainersOptions{All: allContainers})
|
containers, err := client.ListContainers(docker.ListContainersOptions{All: allContainers})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -369,7 +364,7 @@ func GetKubeletDockerContainers(client DockerInterface, allContainers bool) (Doc
|
|||||||
glog.V(3).Infof("Docker Container: %s is not managed by kubelet.", container.Names[0])
|
glog.V(3).Infof("Docker Container: %s is not managed by kubelet.", container.Names[0])
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
result[kubetypes.DockerID(container.ID)] = container
|
result = append(result, container)
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
@ -83,13 +83,14 @@ func TestGetContainerID(t *testing.T) {
|
|||||||
t.Errorf("Expected %#v, Got %#v", fakeDocker.ContainerList, dockerContainers)
|
t.Errorf("Expected %#v, Got %#v", fakeDocker.ContainerList, dockerContainers)
|
||||||
}
|
}
|
||||||
verifyCalls(t, fakeDocker, []string{"list"})
|
verifyCalls(t, fakeDocker, []string{"list"})
|
||||||
dockerContainer, found, _ := dockerContainers.FindPodContainer("qux_ns", "", "foo")
|
|
||||||
|
dockerContainer, found, _ := findPodContainer(dockerContainers, "qux_ns", "", "foo")
|
||||||
if dockerContainer == nil || !found {
|
if dockerContainer == nil || !found {
|
||||||
t.Errorf("Failed to find container %#v", dockerContainer)
|
t.Errorf("Failed to find container %#v", dockerContainer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fakeDocker.ClearCalls()
|
fakeDocker.ClearCalls()
|
||||||
dockerContainer, found, _ = dockerContainers.FindPodContainer("foobar", "", "foo")
|
dockerContainer, found, _ = findPodContainer(dockerContainers, "foobar", "", "foo")
|
||||||
verifyCalls(t, fakeDocker, []string{})
|
verifyCalls(t, fakeDocker, []string{})
|
||||||
if dockerContainer != nil || found {
|
if dockerContainer != nil || found {
|
||||||
t.Errorf("Should not have found container %#v", dockerContainer)
|
t.Errorf("Should not have found container %#v", dockerContainer)
|
||||||
|
@ -356,7 +356,7 @@ func apiContainerToContainer(c docker.APIContainers) kubecontainer.Container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func dockerContainersToPod(containers DockerContainers) kubecontainer.Pod {
|
func dockerContainersToPod(containers []*docker.APIContainers) kubecontainer.Pod {
|
||||||
var pod kubecontainer.Pod
|
var pod kubecontainer.Pod
|
||||||
for _, c := range containers {
|
for _, c := range containers {
|
||||||
dockerName, hash, err := ParseDockerName(c.Names[0])
|
dockerName, hash, err := ParseDockerName(c.Names[0])
|
||||||
|
Loading…
Reference in New Issue
Block a user