From 6cc47b883366fbc6a1c99f5d275fc6fea733984a Mon Sep 17 00:00:00 2001 From: LiuXiang Date: Tue, 27 Aug 2024 17:07:52 +0800 Subject: [PATCH] remove redundant update for performance (#4248) remove redundant update to avoid upper replicas update must has conflict error, although it's in retry.RetryOnConflict() Signed-off-by: LiuXiang --- pkg/ctrl/affinity.go | 8 -------- pkg/ctrl/affinity_test.go | 3 +-- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/pkg/ctrl/affinity.go b/pkg/ctrl/affinity.go index cf392bab7a8..0d5d72d7452 100644 --- a/pkg/ctrl/affinity.go +++ b/pkg/ctrl/affinity.go @@ -17,8 +17,6 @@ limitations under the License. package ctrl import ( - "context" - datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1" "github.com/fluid-cloudnative/fluid/pkg/common" "github.com/fluid-cloudnative/fluid/pkg/utils" @@ -166,12 +164,6 @@ func (e *Helper) BuildWorkersAffinity(workers *appsv1.StatefulSet) (workersToUpd dataset.Spec.NodeAffinity.Required } } - - err = e.client.Update(context.TODO(), workersToUpdate) - if err != nil { - return workersToUpdate, err - } - } return diff --git a/pkg/ctrl/affinity_test.go b/pkg/ctrl/affinity_test.go index 4bb4ec4cb04..693e0a821c0 100644 --- a/pkg/ctrl/affinity_test.go +++ b/pkg/ctrl/affinity_test.go @@ -313,8 +313,7 @@ func TestBuildWorkersAffinityForEFCRuntime(t *testing.T) { }, want: &v1.Affinity{ PodAntiAffinity: &v1.PodAntiAffinity{ - // The fake client makes empty slice to nil - //PreferredDuringSchedulingIgnoredDuringExecution: []v1.WeightedPodAffinityTerm{}, + PreferredDuringSchedulingIgnoredDuringExecution: []v1.WeightedPodAffinityTerm{}, RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ { LabelSelector: &metav1.LabelSelector{