Merge pull request #3051 from brendandburns/flake

Add a PodUnknown phase and make ListPods return even when there are errors
This commit is contained in:
Daniel Smith 2014-12-19 16:45:44 -08:00
commit 9fee1b0503
10 changed files with 24 additions and 6 deletions

View File

@ -65,7 +65,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
j.FieldPath = c.RandString() j.FieldPath = c.RandString()
}, },
func(j *internal.PodPhase, c fuzz.Continue) { func(j *internal.PodPhase, c fuzz.Continue) {
statuses := []internal.PodPhase{internal.PodPending, internal.PodRunning, internal.PodFailed} statuses := []internal.PodPhase{internal.PodPending, internal.PodRunning, internal.PodFailed, internal.PodUnknown}
*j = statuses[c.Rand.Intn(len(statuses))] *j = statuses[c.Rand.Intn(len(statuses))]
}, },
func(j *internal.ReplicationControllerSpec, c fuzz.Continue) { func(j *internal.ReplicationControllerSpec, c fuzz.Continue) {

View File

@ -69,7 +69,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
j.SelfLink = c.RandString() j.SelfLink = c.RandString()
}, },
func(j *api.PodPhase, c fuzz.Continue) { func(j *api.PodPhase, c fuzz.Continue) {
statuses := []api.PodPhase{api.PodPending, api.PodRunning, api.PodFailed} statuses := []api.PodPhase{api.PodPending, api.PodRunning, api.PodFailed, api.PodUnknown}
*j = statuses[c.Rand.Intn(len(statuses))] *j = statuses[c.Rand.Intn(len(statuses))]
}, },
func(j *api.ReplicationControllerSpec, c fuzz.Continue) { func(j *api.ReplicationControllerSpec, c fuzz.Continue) {

View File

@ -365,6 +365,9 @@ const (
// PodFailed means that all containers in the pod have terminated, and at least one container has // PodFailed means that all containers in the pod have terminated, and at least one container has
// terminated in a failure (exited with a non-zero exit code or was stopped by the system). // terminated in a failure (exited with a non-zero exit code or was stopped by the system).
PodFailed PodPhase = "Failed" PodFailed PodPhase = "Failed"
// PodUnknown means that for some reason the state of the pod could not be obtained, typically due
// to an error in communicating with the host of the pod.
PodUnknown PodPhase = "Unknown"
) )
type ContainerStateWaiting struct { type ContainerStateWaiting struct {

View File

@ -228,6 +228,8 @@ func init() {
*out = PodTerminated *out = PodTerminated
case newer.PodFailed: case newer.PodFailed:
*out = PodTerminated *out = PodTerminated
case newer.PodUnknown:
*out = PodUnknown
default: default:
return errors.New("The string provided is not a valid PodPhase constant value") return errors.New("The string provided is not a valid PodPhase constant value")
} }
@ -246,6 +248,8 @@ func init() {
case PodTerminated: case PodTerminated:
// Older API versions did not contain enough info to map to PodSucceeded // Older API versions did not contain enough info to map to PodSucceeded
*out = newer.PodFailed *out = newer.PodFailed
case PodUnknown:
*out = newer.PodUnknown
default: default:
return errors.New("The string provided is not a valid PodPhase constant value") return errors.New("The string provided is not a valid PodPhase constant value")
} }

View File

@ -319,6 +319,8 @@ const (
PodRunning PodStatus = "Running" PodRunning PodStatus = "Running"
// PodTerminated means that the pod has stopped. // PodTerminated means that the pod has stopped.
PodTerminated PodStatus = "Terminated" PodTerminated PodStatus = "Terminated"
// PodUnknown means that we failed to obtain info about the pod.
PodUnknown PodStatus = "Unknown"
) )
type ContainerStateWaiting struct { type ContainerStateWaiting struct {

View File

@ -116,6 +116,8 @@ func init() {
*out = PodTerminated *out = PodTerminated
case newer.PodFailed: case newer.PodFailed:
*out = PodTerminated *out = PodTerminated
case newer.PodUnknown:
*out = PodUnknown
default: default:
return errors.New("The string provided is not a valid PodPhase constant value") return errors.New("The string provided is not a valid PodPhase constant value")
} }
@ -134,6 +136,8 @@ func init() {
case PodTerminated: case PodTerminated:
// Older API versions did not contain enough info to map to PodSucceeded // Older API versions did not contain enough info to map to PodSucceeded
*out = newer.PodFailed *out = newer.PodFailed
case PodUnknown:
*out = newer.PodUnknown
default: default:
return errors.New("The string provided is not a valid PodPhase constant value") return errors.New("The string provided is not a valid PodPhase constant value")
} }

View File

@ -284,6 +284,8 @@ const (
PodRunning PodStatus = "Running" PodRunning PodStatus = "Running"
// PodTerminated means that the pod has stopped. // PodTerminated means that the pod has stopped.
PodTerminated PodStatus = "Terminated" PodTerminated PodStatus = "Terminated"
// PodUnknown means that we failed to obtain info about the pod.
PodUnknown PodStatus = "Unknown"
) )
type ContainerStateWaiting struct { type ContainerStateWaiting struct {

View File

@ -381,6 +381,9 @@ const (
// PodFailed means that all containers in the pod have terminated, and at least one container has // PodFailed means that all containers in the pod have terminated, and at least one container has
// terminated in a failure (exited with a non-zero exit code or was stopped by the system). // terminated in a failure (exited with a non-zero exit code or was stopped by the system).
PodFailed PodPhase = "Failed" PodFailed PodPhase = "Failed"
// PodUnknown means that for some reason the state of the pod could not be obtained, typically due
// to an error in communicating with the host of the pod.
PodUnknown PodPhase = "Unknown"
) )
type ContainerStateWaiting struct { type ContainerStateWaiting struct {

View File

@ -71,7 +71,7 @@ var apiObjectFuzzer = fuzz.New().NilChance(.5).NumElements(1, 1).Funcs(
j.SelfLink = c.RandString() j.SelfLink = c.RandString()
}, },
func(j *api.PodPhase, c fuzz.Continue) { func(j *api.PodPhase, c fuzz.Continue) {
statuses := []api.PodPhase{api.PodPending, api.PodRunning, api.PodFailed} statuses := []api.PodPhase{api.PodPending, api.PodRunning, api.PodFailed, api.PodUnknown}
*j = statuses[c.Rand.Intn(len(statuses))] *j = statuses[c.Rand.Intn(len(statuses))]
}, },
func(j *api.ReplicationControllerSpec, c fuzz.Continue) { func(j *api.ReplicationControllerSpec, c fuzz.Continue) {

View File

@ -171,7 +171,7 @@ func (rs *REST) List(ctx api.Context, label, field labels.Selector) (runtime.Obj
rs.fillPodInfo(pod) rs.fillPodInfo(pod)
status, err := getPodStatus(pod, rs.nodes) status, err := getPodStatus(pod, rs.nodes)
if err != nil { if err != nil {
return pod, err status = api.PodUnknown
} }
pod.Status.Phase = status pod.Status.Phase = status
if pod.Status.Host != "" { if pod.Status.Host != "" {
@ -285,8 +285,8 @@ func getPodStatus(pod *api.Pod, nodes client.NodeInterface) (api.PodPhase, error
if errors.IsNotFound(err) { if errors.IsNotFound(err) {
return api.PodFailed, nil return api.PodFailed, nil
} }
glog.Errorf("Error listing minions: %v", err) glog.Errorf("Error getting pod info: %v", err)
return "", err return api.PodUnknown, nil
} }
} else { } else {
glog.Errorf("Unexpected missing minion interface, status may be in-accurate") glog.Errorf("Unexpected missing minion interface, status may be in-accurate")