@@ -226,21 +226,24 @@ func (m *manager) SetContainerReadiness(podUID types.UID, containerID kubecontai
226
226
containerStatus , _ , _ = findContainerStatus (& status , containerID .String ())
227
227
containerStatus .Ready = ready
228
228
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 )
235
243
}
236
244
}
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 ))
244
247
m .updateStatusInternal (pod , status , false )
245
248
}
246
249
0 commit comments