From 2f576969eeeb72c6a3ecea6264d0d536e7164378 Mon Sep 17 00:00:00 2001 From: lowang-bh Date: Sun, 20 Aug 2023 19:36:50 +0800 Subject: [PATCH] reducae function calling to once Signed-off-by: lowang-bh --- pkg/controller/statefulset/stateful_set_control.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/controller/statefulset/stateful_set_control.go b/pkg/controller/statefulset/stateful_set_control.go index f55b7d1d67c..f0803bd68eb 100644 --- a/pkg/controller/statefulset/stateful_set_control.go +++ b/pkg/controller/statefulset/stateful_set_control.go @@ -337,10 +337,11 @@ func computeReplicaStatus(pods []*v1.Pod, minReadySeconds int32, currentRevision // count the number of current and update replicas if isCreated(pod) && !isTerminating(pod) { - if getPodRevision(pod) == currentRevision.Name { + revision := getPodRevision(pod) + if revision == currentRevision.Name { status.currentReplicas++ } - if getPodRevision(pod) == updateRevision.Name { + if revision == updateRevision.Name { status.updatedReplicas++ } }