Skip to content

Commit

Permalink
sync podCondition when probe message of NodePodProbe changed
Browse files Browse the repository at this point in the history
Signed-off-by: ChrisLiu <[email protected]>
  • Loading branch information
chrisliu1995 committed Dec 28, 2023
1 parent fa9a9a0 commit c1d439f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/controller/nodepodprobe/node_pod_probe_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (r *ReconcileNodePodProbe) updatePodProbeStatus(pod *corev1.Pod, status app
oldStatus := podClone.Status.DeepCopy()
for i := range probeConditions {
condition := probeConditions[i]
util.SetPodCondition(podClone, condition)
util.SetPodConditionIfMsgChanged(podClone, condition)
}
oldMetadata := podClone.ObjectMeta.DeepCopy()
if podClone.Annotations == nil {
Expand Down
12 changes: 12 additions & 0 deletions pkg/util/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,18 @@ func SetPodCondition(pod *v1.Pod, condition v1.PodCondition) {
pod.Status.Conditions = append(pod.Status.Conditions, condition)
}

func SetPodConditionIfMsgChanged(pod *v1.Pod, condition v1.PodCondition) {
for i, c := range pod.Status.Conditions {
if c.Type == condition.Type {
if c.Status != condition.Status || c.Message != condition.Message {
pod.Status.Conditions[i] = condition
}
return

Check warning on line 313 in pkg/util/pods.go

View check run for this annotation

Codecov / codecov/patch

pkg/util/pods.go#L307-L313

Added lines #L307 - L313 were not covered by tests
}
}
pod.Status.Conditions = append(pod.Status.Conditions, condition)

Check warning on line 316 in pkg/util/pods.go

View check run for this annotation

Codecov / codecov/patch

pkg/util/pods.go#L316

Added line #L316 was not covered by tests
}

func SetPodReadyCondition(pod *v1.Pod) {
podReady := GetCondition(pod, v1.PodReady)
if podReady == nil {
Expand Down

0 comments on commit c1d439f

Please sign in to comment.