From 17cbde0c5a0a8c77546ab46d853c579a76c93987 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Wed, 17 Sep 2014 21:57:11 -0700 Subject: [PATCH] Adjust the logic, so that if the apiserver restarts, or has no pod info for some other reason, pods on missing machines are still 'terminated' --- pkg/registry/pod/rest.go | 5 ++++- pkg/registry/pod/rest_test.go | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/registry/pod/rest.go b/pkg/registry/pod/rest.go index d3493f73374..af7189cf43c 100644 --- a/pkg/registry/pod/rest.go +++ b/pkg/registry/pod/rest.go @@ -214,7 +214,7 @@ func getInstanceIP(cloud cloudprovider.Interface, host string) string { } func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodStatus, error) { - if pod.CurrentState.Info == nil || pod.CurrentState.Host == "" { + if pod.CurrentState.Host == "" { return api.PodWaiting, nil } res, err := minions.ListMinions() @@ -232,6 +232,9 @@ func getPodStatus(pod *api.Pod, minions client.MinionInterface) (api.PodStatus, if !found { return api.PodTerminated, nil } + if pod.CurrentState.Info == nil { + return api.PodWaiting, nil + } running := 0 stopped := 0 unknown := 0 diff --git a/pkg/registry/pod/rest_test.go b/pkg/registry/pod/rest_test.go index 3e3c5571833..2183005ef72 100644 --- a/pkg/registry/pod/rest_test.go +++ b/pkg/registry/pod/rest_test.go @@ -296,6 +296,16 @@ func TestMakePodStatus(t *testing.T) { test string }{ {&api.Pod{DesiredState: desiredState, CurrentState: currentState}, api.PodWaiting, "waiting"}, + { + &api.Pod{ + DesiredState: desiredState, + CurrentState: api.PodState{ + Host: "machine-2", + }, + }, + api.PodTerminated, + "no info, but bad machine", + }, { &api.Pod{ DesiredState: desiredState,