mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
export kubelet.GetPhase
This commit is contained in:
parent
ccb1b658b2
commit
3cf7739b42
@ -1960,8 +1960,10 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPhase returns the phase of a pod given its container info.
|
// GetPhase returns the phase of a pod given its container info.
|
||||||
func getPhase(spec *api.PodSpec, info []api.ContainerStatus) api.PodPhase {
|
// 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
|
running := 0
|
||||||
waiting := 0
|
waiting := 0
|
||||||
stopped := 0
|
stopped := 0
|
||||||
@ -2080,7 +2082,7 @@ func (kl *Kubelet) generatePodStatus(pod *api.Pod) (api.PodStatus, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assume info is ready to process
|
// Assume info is ready to process
|
||||||
podStatus.Phase = getPhase(spec, podStatus.ContainerStatuses)
|
podStatus.Phase = GetPhase(spec, podStatus.ContainerStatuses)
|
||||||
for _, c := range spec.Containers {
|
for _, c := range spec.Containers {
|
||||||
for i, st := range podStatus.ContainerStatuses {
|
for i, st := range podStatus.ContainerStatuses {
|
||||||
if st.Name == c.Name {
|
if st.Name == c.Name {
|
||||||
|
@ -1657,7 +1657,7 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
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)
|
t.Errorf("In test %s, expected %v, got %v", test.test, test.status, status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1745,7 +1745,7 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
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)
|
t.Errorf("In test %s, expected %v, got %v", test.test, test.status, status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1833,7 +1833,7 @@ func TestPodPhaseWithRestartOnFailure(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
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)
|
t.Errorf("In test %s, expected %v, got %v", test.test, test.status, status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user