Merge pull request #65567 from ceshihao/pod_status_after_eviction

Pod status should contain ContainerStatuses if deadline exceeded
pull/58/head
k8s-ci-robot 2018-10-17 11:56:41 -07:00 committed by GitHub
commit e85cb406eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -1323,19 +1323,18 @@ func getPhase(spec *v1.PodSpec, info []v1.ContainerStatus) v1.PodPhase {
func (kl *Kubelet) generateAPIPodStatus(pod *v1.Pod, podStatus *kubecontainer.PodStatus) v1.PodStatus {
glog.V(3).Infof("Generating status for %q", format.Pod(pod))
s := kl.convertStatusToAPIStatus(pod, podStatus)
// check if an internal module has requested the pod is evicted.
for _, podSyncHandler := range kl.PodSyncHandlers {
if result := podSyncHandler.ShouldEvict(pod); result.Evict {
return v1.PodStatus{
Phase: v1.PodFailed,
Reason: result.Reason,
Message: result.Message,
}
s.Phase = v1.PodFailed
s.Reason = result.Reason
s.Message = result.Message
return *s
}
}
s := kl.convertStatusToAPIStatus(pod, podStatus)
// Assume info is ready to process
spec := &pod.Spec
allStatus := append(append([]v1.ContainerStatus{}, s.ContainerStatuses...), s.InitContainerStatuses...)

View File

@ -1432,6 +1432,8 @@ func TestSyncPodsSetStatusToFailedForPodsThatRunTooLong(t *testing.T) {
status, found := kubelet.statusManager.GetPodStatus(pods[0].UID)
assert.True(t, found, "expected to found status for pod %q", pods[0].UID)
assert.Equal(t, v1.PodFailed, status.Phase)
// check pod status contains ContainerStatuses, etc.
assert.NotNil(t, status.ContainerStatuses)
}
func TestSyncPodsDoesNotSetPodsThatDidNotRunTooLongToFailed(t *testing.T) {