From 795e2575dc0ef89ca950180185172fefba4f62a8 Mon Sep 17 00:00:00 2001 From: Rory Z <16801068+Rory-Z@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:22:50 +0800 Subject: [PATCH] chore: don't always change lastTransitionTime of pod conditon' Signed-off-by: Rory Z <16801068+Rory-Z@users.noreply.github.com> --- controllers/apps/v2beta1/update_pod_conditions.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/apps/v2beta1/update_pod_conditions.go b/controllers/apps/v2beta1/update_pod_conditions.go index 2b61429a4..3bab73c6e 100644 --- a/controllers/apps/v2beta1/update_pod_conditions.go +++ b/controllers/apps/v2beta1/update_pod_conditions.go @@ -40,7 +40,6 @@ func (u *updatePodConditions) reconcile(ctx context.Context, logger logr.Logger, onServingCondition := corev1.PodCondition{ Type: appsv2beta1.PodOnServing, Status: corev1.ConditionFalse, - LastProbeTime: metav1.Now(), LastTransitionTime: metav1.Now(), } @@ -68,6 +67,11 @@ func (u *updatePodConditions) reconcile(ctx context.Context, logger logr.Logger, } } + for _, condition := range pod.Status.Conditions { + if condition.Type == appsv2beta1.PodOnServing && condition.Status == onServingCondition.Status { + onServingCondition.LastTransitionTime = condition.LastTransitionTime + } + } patchBytes, _ := json.Marshal(corev1.Pod{ Status: corev1.PodStatus{ Conditions: []corev1.PodCondition{onServingCondition},