From 8964469e4a672b5cc894cd9d56ed591741c5f630 Mon Sep 17 00:00:00 2001 From: Yifan Gu Date: Tue, 9 Feb 2016 00:15:58 +0800 Subject: [PATCH] rkt: Remove ShouldContainerBeRestartedOldVersion(). --- pkg/kubelet/container/helpers.go | 28 ---------------------------- pkg/kubelet/rkt/rkt.go | 2 +- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/pkg/kubelet/container/helpers.go b/pkg/kubelet/container/helpers.go index 21362744f49..f5346950b61 100644 --- a/pkg/kubelet/container/helpers.go +++ b/pkg/kubelet/container/helpers.go @@ -72,34 +72,6 @@ func ShouldContainerBeRestarted(container *api.Container, pod *api.Pod, podStatu return true } -// TODO(random-liu): This should be removed soon after rkt implements GetPodStatus. -func ShouldContainerBeRestartedOldVersion(container *api.Container, pod *api.Pod, podStatus *api.PodStatus) bool { - // Get all dead container status. - var resultStatus []*api.ContainerStatus - for i, containerStatus := range podStatus.ContainerStatuses { - if containerStatus.Name == container.Name && containerStatus.State.Terminated != nil { - resultStatus = append(resultStatus, &podStatus.ContainerStatuses[i]) - } - } - - // Check RestartPolicy for dead container. - if len(resultStatus) > 0 { - if pod.Spec.RestartPolicy == api.RestartPolicyNever { - glog.V(4).Infof("Already ran container %q of pod %q, do nothing", container.Name, format.Pod(pod)) - return false - } - if pod.Spec.RestartPolicy == api.RestartPolicyOnFailure { - // Check the exit code of last run. Note: This assumes the result is sorted - // by the created time in reverse order. - if resultStatus[0].State.Terminated.ExitCode == 0 { - glog.V(4).Infof("Already successfully ran container %q of pod %q, do nothing", container.Name, format.Pod(pod)) - return false - } - } - } - return true -} - // TODO(random-liu): Convert PodStatus to running Pod, should be deprecated soon func ConvertPodStatusToRunningPod(podStatus *PodStatus) Pod { runningPod := Pod{ diff --git a/pkg/kubelet/rkt/rkt.go b/pkg/kubelet/rkt/rkt.go index 0b5067d1a95..cc0c5dcde0b 100644 --- a/pkg/kubelet/rkt/rkt.go +++ b/pkg/kubelet/rkt/rkt.go @@ -1088,7 +1088,7 @@ func (r *Runtime) SyncPod(pod *api.Pod, podStatus api.PodStatus, internalPodStat c := runningPod.FindContainerByName(container.Name) if c == nil { - if kubecontainer.ShouldContainerBeRestartedOldVersion(&container, pod, &podStatus) { + if kubecontainer.ShouldContainerBeRestarted(&container, pod, internalPodStatus) { glog.V(3).Infof("Container %+v is dead, but RestartPolicy says that we should restart it.", container) // TODO(yifan): Containers in one pod are fate-sharing at this moment, see: // https://github.com/appc/spec/issues/276.