Skip to content

Commit 1eaa0f2

Browse files
authored
sync podCondition when probe message of NodePodProbe changed (openkruise#1479)
1 parent 95cf9be commit 1eaa0f2

File tree

5 files changed

+839
-2
lines changed

5 files changed

+839
-2
lines changed

Diff for: pkg/controller/nodepodprobe/node_pod_probe_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func (r *ReconcileNodePodProbe) updatePodProbeStatus(pod *corev1.Pod, status app
333333
oldStatus := podClone.Status.DeepCopy()
334334
for i := range probeConditions {
335335
condition := probeConditions[i]
336-
util.SetPodCondition(podClone, condition)
336+
util.SetPodConditionIfMsgChanged(podClone, condition)
337337
}
338338
oldMetadata := podClone.ObjectMeta.DeepCopy()
339339
if podClone.Annotations == nil {

Diff for: pkg/util/pods.go

+12
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,18 @@ func SetPodCondition(pod *v1.Pod, condition v1.PodCondition) {
304304
pod.Status.Conditions = append(pod.Status.Conditions, condition)
305305
}
306306

307+
func SetPodConditionIfMsgChanged(pod *v1.Pod, condition v1.PodCondition) {
308+
for i, c := range pod.Status.Conditions {
309+
if c.Type == condition.Type {
310+
if c.Status != condition.Status || c.Message != condition.Message {
311+
pod.Status.Conditions[i] = condition
312+
}
313+
return
314+
}
315+
}
316+
pod.Status.Conditions = append(pod.Status.Conditions, condition)
317+
}
318+
307319
func SetPodReadyCondition(pod *v1.Pod) {
308320
podReady := GetCondition(pod, v1.PodReady)
309321
if podReady == nil {

0 commit comments

Comments
 (0)