From 10f3152fa02df12bd51c7cdc8660b71186d1b797 Mon Sep 17 00:00:00 2001 From: LivingCcj Date: Sat, 12 Oct 2024 21:13:45 +0800 Subject: [PATCH] add ResourceSummary deep copy in general-estimator Signed-off-by: LivingCcj --- pkg/estimator/client/general.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/estimator/client/general.go b/pkg/estimator/client/general.go index 6023c89f528a..46d3c40d92ce 100644 --- a/pkg/estimator/client/general.go +++ b/pkg/estimator/client/general.go @@ -54,7 +54,8 @@ func (ge *GeneralEstimator) MaxAvailableReplicas(_ context.Context, clusters []* } func (ge *GeneralEstimator) maxAvailableReplicas(cluster *clusterv1alpha1.Cluster, replicaRequirements *workv1alpha2.ReplicaRequirements) int32 { - resourceSummary := cluster.Status.ResourceSummary + //Note: resourceSummary must be deep-copied before using in the function to avoid modifying the original data structure. + resourceSummary := cluster.Status.ResourceSummary.DeepCopy() if resourceSummary == nil { return 0 }