Skip to content

Commit 370268f

Browse files
committed
Inject ContainersReady
1 parent 176f34e commit 370268f

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

pkg/kubelet/kubelet_pods.go

+1
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,7 @@ func (kl *Kubelet) generateAPIPodStatus(pod *v1.Pod, podStatus *kubecontainer.Po
13541354
kl.probeManager.UpdatePodStatus(pod.UID, s)
13551355
s.Conditions = append(s.Conditions, status.GeneratePodInitializedCondition(spec, s.InitContainerStatuses, s.Phase))
13561356
s.Conditions = append(s.Conditions, status.GeneratePodReadyCondition(spec, s.Conditions, s.ContainerStatuses, s.Phase))
1357+
s.Conditions = append(s.Conditions, status.GenerateContainersReadyCondition(spec, s.ContainerStatuses, s.Phase))
13571358
// Status manager will take care of the LastTransitionTimestamp, either preserve
13581359
// the timestamp from apiserver, or set a new one. When kubelet sees the pod,
13591360
// `PodScheduled` condition must be true.

pkg/kubelet/status/status_manager.go

+16-13
Original file line numberDiff line numberDiff line change
@@ -226,21 +226,24 @@ func (m *manager) SetContainerReadiness(podUID types.UID, containerID kubecontai
226226
containerStatus, _, _ = findContainerStatus(&status, containerID.String())
227227
containerStatus.Ready = ready
228228

229-
// Update pod condition.
230-
podReadyConditionIndex := -1
231-
for i, condition := range status.Conditions {
232-
if condition.Type == v1.PodReady {
233-
podReadyConditionIndex = i
234-
break
229+
// updateConditionFunc updates the corresponding type of condition
230+
updateConditionFunc := func(conditionType v1.PodConditionType, condition v1.PodCondition) {
231+
conditionIndex := -1
232+
for i, condition := range status.Conditions {
233+
if condition.Type == conditionType {
234+
conditionIndex = i
235+
break
236+
}
237+
}
238+
if conditionIndex != -1 {
239+
status.Conditions[conditionIndex] = condition
240+
} else {
241+
glog.Warningf("PodStatus missing %s type condition: %+v", conditionType, status)
242+
status.Conditions = append(status.Conditions, condition)
235243
}
236244
}
237-
podReady := GeneratePodReadyCondition(&pod.Spec, status.Conditions, status.ContainerStatuses, status.Phase)
238-
if podReadyConditionIndex != -1 {
239-
status.Conditions[podReadyConditionIndex] = podReady
240-
} else {
241-
glog.Warningf("PodStatus missing PodReady condition: %+v", status)
242-
status.Conditions = append(status.Conditions, podReady)
243-
}
245+
updateConditionFunc(v1.PodReady, GeneratePodReadyCondition(&pod.Spec, status.Conditions, status.ContainerStatuses, status.Phase))
246+
updateConditionFunc(v1.ContainersReady, GenerateContainersReadyCondition(&pod.Spec, status.ContainerStatuses, status.Phase))
244247
m.updateStatusInternal(pod, status, false)
245248
}
246249

0 commit comments

Comments
 (0)