Skip to content

Commit

Permalink
sync podCondition when probe message of NodePodProbe changed (openkru…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisliu1995 authored Jan 11, 2024
1 parent 95cf9be commit 1eaa0f2
Show file tree
Hide file tree
Showing 5 changed files with 839 additions and 2 deletions.
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
}
}
pod.Status.Conditions = append(pod.Status.Conditions, condition)
}

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

0 comments on commit 1eaa0f2

Please sign in to comment.