Commit 7b4cdb6f authored by Random-Liu's avatar Random-Liu Committed by Lantao Liu

Remove GetAPIPodStatus from runtime interface

parent 41b12a18
...@@ -236,15 +236,6 @@ func (f *FakeRuntime) KillContainerInPod(container api.Container, pod *api.Pod) ...@@ -236,15 +236,6 @@ func (f *FakeRuntime) KillContainerInPod(container api.Container, pod *api.Pod)
return f.Err return f.Err
} }
func (f *FakeRuntime) GetAPIPodStatus(*api.Pod) (*api.PodStatus, error) {
f.Lock()
defer f.Unlock()
f.CalledFunctions = append(f.CalledFunctions, "GetAPIPodStatus")
status := f.APIPodStatus
return &status, f.Err
}
func (f *FakeRuntime) GetPodStatus(uid types.UID, name, namespace string) (*PodStatus, error) { func (f *FakeRuntime) GetPodStatus(uid types.UID, name, namespace string) (*PodStatus, error) {
f.Lock() f.Lock()
defer f.Unlock() defer f.Unlock()
......
...@@ -69,11 +69,6 @@ type Runtime interface { ...@@ -69,11 +69,6 @@ type Runtime interface {
// KillPod kills all the containers of a pod. Pod may be nil, running pod must not be. // KillPod kills all the containers of a pod. Pod may be nil, running pod must not be.
// TODO(random-liu): Return PodSyncResult in KillPod. // TODO(random-liu): Return PodSyncResult in KillPod.
KillPod(pod *api.Pod, runningPod Pod) error KillPod(pod *api.Pod, runningPod Pod) error
// GetAPIPodStatus retrieves the api.PodStatus of the pod, including the information of
// all containers in the pod. Clients of this interface assume the
// containers' statuses in a pod always have a deterministic ordering
// (e.g., sorted by name).
GetAPIPodStatus(*api.Pod) (*api.PodStatus, error)
// 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 visble in Runtime. // information of all containers in the pod that are visble in Runtime.
GetPodStatus(uid types.UID, name, namespace string) (*PodStatus, error) GetPodStatus(uid types.UID, name, namespace string) (*PodStatus, error)
......
...@@ -77,11 +77,6 @@ func (r *Mock) KillContainerInPod(container api.Container, pod *api.Pod) error { ...@@ -77,11 +77,6 @@ func (r *Mock) KillContainerInPod(container api.Container, pod *api.Pod) error {
return args.Error(0) return args.Error(0)
} }
func (r *Mock) GetAPIPodStatus(pod *api.Pod) (*api.PodStatus, error) {
args := r.Called(pod)
return args.Get(0).(*api.PodStatus), args.Error(1)
}
func (r *Mock) GetPodStatus(uid types.UID, name, namespace string) (*PodStatus, error) { func (r *Mock) GetPodStatus(uid types.UID, name, namespace string) (*PodStatus, error) {
args := r.Called(uid, name, namespace) args := r.Called(uid, name, namespace)
return args.Get(0).(*PodStatus), args.Error(1) return args.Get(0).(*PodStatus), args.Error(1)
......
...@@ -250,7 +250,7 @@ func (f *FakeDockerClient) CreateContainer(c docker.CreateContainerOptions) (*do ...@@ -250,7 +250,7 @@ func (f *FakeDockerClient) CreateContainer(c docker.CreateContainerOptions) (*do
// Docker likes to add a '/', so copy that behavior. // Docker likes to add a '/', so copy that behavior.
name := "/" + c.Name name := "/" + c.Name
f.Created = append(f.Created, name) f.Created = append(f.Created, name)
// The newest container should be in front, because we assume so in GetAPIPodStatus() // The newest container should be in front, because we assume so in GetPodStatus()
f.ContainerList = append([]docker.APIContainers{ f.ContainerList = append([]docker.APIContainers{
{ID: name, Names: []string{name}, Image: c.Config.Image, Labels: c.Config.Labels}, {ID: name, Names: []string{name}, Image: c.Config.Image, Labels: c.Config.Labels},
}, f.ContainerList...) }, f.ContainerList...)
...@@ -300,7 +300,7 @@ func (f *FakeDockerClient) StopContainer(id string, timeout uint) error { ...@@ -300,7 +300,7 @@ func (f *FakeDockerClient) StopContainer(id string, timeout uint) error {
var newList []docker.APIContainers var newList []docker.APIContainers
for _, container := range f.ContainerList { for _, container := range f.ContainerList {
if container.ID == id { if container.ID == id {
// The newest exited container should be in front. Because we assume so in GetAPIPodStatus() // The newest exited container should be in front. Because we assume so in GetPodStatus()
f.ExitedContainerList = append([]docker.APIContainers{container}, f.ExitedContainerList...) f.ExitedContainerList = append([]docker.APIContainers{container}, f.ExitedContainerList...)
continue continue
} }
......
...@@ -104,8 +104,7 @@ type DockerManager struct { ...@@ -104,8 +104,7 @@ type DockerManager struct {
// means that some entries may be recycled before a pod has been // means that some entries may be recycled before a pod has been
// deleted. // deleted.
reasonCache reasonInfoCache reasonCache reasonInfoCache
// TODO(yifan): Record the pull failure so we can eliminate the image checking // TODO(yifan): Record the pull failure so we can eliminate the image checking?
// in GetAPIPodStatus()?
// Lower level docker image puller. // Lower level docker image puller.
dockerPuller DockerPuller dockerPuller DockerPuller
...@@ -419,17 +418,6 @@ func (dm *DockerManager) inspectContainer(id string, podName, podNamespace strin ...@@ -419,17 +418,6 @@ func (dm *DockerManager) inspectContainer(id string, podName, podNamespace strin
return &status, "", nil return &status, "", nil
} }
// GetAPIPodStatus returns docker related status for all containers in the pod
// spec.
func (dm *DockerManager) GetAPIPodStatus(pod *api.Pod) (*api.PodStatus, error) {
// Get the pod status.
podStatus, err := dm.GetPodStatus(pod.UID, pod.Name, pod.Namespace)
if err != nil {
return nil, err
}
return dm.ConvertPodStatusToAPIPodStatus(pod, podStatus)
}
func (dm *DockerManager) ConvertPodStatusToAPIPodStatus(pod *api.Pod, podStatus *kubecontainer.PodStatus) (*api.PodStatus, error) { func (dm *DockerManager) ConvertPodStatusToAPIPodStatus(pod *api.Pod, podStatus *kubecontainer.PodStatus) (*api.PodStatus, error) {
var apiPodStatus api.PodStatus var apiPodStatus api.PodStatus
uid := pod.UID uid := pod.UID
......
...@@ -4348,3 +4348,5 @@ func TestGetPodsToSync(t *testing.T) { ...@@ -4348,3 +4348,5 @@ func TestGetPodsToSync(t *testing.T) {
t.Errorf("expected %d pods to sync, got %d", 3, len(podsToSync)) t.Errorf("expected %d pods to sync, got %d", 3, len(podsToSync))
} }
} }
// TODO(random-liu): Add unit test for convertStatusToAPIStatus (issue #20478)
...@@ -1009,16 +1009,6 @@ func (r *Runtime) KillPod(pod *api.Pod, runningPod kubecontainer.Pod) error { ...@@ -1009,16 +1009,6 @@ func (r *Runtime) KillPod(pod *api.Pod, runningPod kubecontainer.Pod) error {
return nil return nil
} }
// GetAPIPodStatus returns the status of the given pod.
func (r *Runtime) GetAPIPodStatus(pod *api.Pod) (*api.PodStatus, error) {
// Get the pod status.
podStatus, err := r.GetPodStatus(pod.UID, pod.Name, pod.Namespace)
if err != nil {
return nil, err
}
return r.ConvertPodStatusToAPIPodStatus(pod, podStatus)
}
func (r *Runtime) Type() string { func (r *Runtime) Type() string {
return RktType return RktType
} }
......
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