Merge pull request #20817 from yifan-gu/remove_ShouldContainerBeRestartedOldVersion

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2016-02-09 04:36:36 -08:00
commit 71bcc25409
2 changed files with 1 additions and 29 deletions

View File

@ -72,34 +72,6 @@ func ShouldContainerBeRestarted(container *api.Container, pod *api.Pod, podStatu
return true 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 // TODO(random-liu): Convert PodStatus to running Pod, should be deprecated soon
func ConvertPodStatusToRunningPod(podStatus *PodStatus) Pod { func ConvertPodStatusToRunningPod(podStatus *PodStatus) Pod {
runningPod := Pod{ runningPod := Pod{

View File

@ -1088,7 +1088,7 @@ func (r *Runtime) SyncPod(pod *api.Pod, podStatus api.PodStatus, internalPodStat
c := runningPod.FindContainerByName(container.Name) c := runningPod.FindContainerByName(container.Name)
if c == nil { 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) 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: // TODO(yifan): Containers in one pod are fate-sharing at this moment, see:
// https://github.com/appc/spec/issues/276. // https://github.com/appc/spec/issues/276.