mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Merge pull request #9710 from mesosphere/public-get-phase
export kubelet.GetPhase
This commit is contained in:
commit
928971cea4
@ -1991,8 +1991,10 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// getPhase returns the phase of a pod given its container info.
|
||||
func getPhase(spec *api.PodSpec, info []api.ContainerStatus) api.PodPhase {
|
||||
// GetPhase returns the phase of a pod given its container info.
|
||||
// This func is exported to simplify integration with 3rd party kubelet
|
||||
// integrations like kubernetes-mesos.
|
||||
func GetPhase(spec *api.PodSpec, info []api.ContainerStatus) api.PodPhase {
|
||||
running := 0
|
||||
waiting := 0
|
||||
stopped := 0
|
||||
@ -2111,7 +2113,7 @@ func (kl *Kubelet) generatePodStatus(pod *api.Pod) (api.PodStatus, error) {
|
||||
}
|
||||
|
||||
// Assume info is ready to process
|
||||
podStatus.Phase = getPhase(spec, podStatus.ContainerStatuses)
|
||||
podStatus.Phase = GetPhase(spec, podStatus.ContainerStatuses)
|
||||
for _, c := range spec.Containers {
|
||||
for i, st := range podStatus.ContainerStatuses {
|
||||
if st.Name == c.Name {
|
||||
|
@ -1656,7 +1656,7 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
if status := getPhase(&test.pod.Spec, test.pod.Status.ContainerStatuses); status != test.status {
|
||||
if status := GetPhase(&test.pod.Spec, test.pod.Status.ContainerStatuses); status != test.status {
|
||||
t.Errorf("In test %s, expected %v, got %v", test.test, test.status, status)
|
||||
}
|
||||
}
|
||||
@ -1744,7 +1744,7 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
if status := getPhase(&test.pod.Spec, test.pod.Status.ContainerStatuses); status != test.status {
|
||||
if status := GetPhase(&test.pod.Spec, test.pod.Status.ContainerStatuses); status != test.status {
|
||||
t.Errorf("In test %s, expected %v, got %v", test.test, test.status, status)
|
||||
}
|
||||
}
|
||||
@ -1832,7 +1832,7 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
if status := getPhase(&test.pod.Spec, test.pod.Status.ContainerStatuses); status != test.status {
|
||||
if status := GetPhase(&test.pod.Spec, test.pod.Status.ContainerStatuses); status != test.status {
|
||||
t.Errorf("In test %s, expected %v, got %v", test.test, test.status, status)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user