From cf4693901980f6005a9585f625cb90c2614a0dbb Mon Sep 17 00:00:00 2001 From: Monokaix Date: Fri, 17 Jan 2025 15:05:14 +0800 Subject: [PATCH] fix pp suspension mistakenly override scheduling suspension Signed-off-by: Monokaix --- .../multiclusterservice/mcs_controller.go | 7 ++++++- pkg/detector/detector.go | 21 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pkg/controllers/multiclusterservice/mcs_controller.go b/pkg/controllers/multiclusterservice/mcs_controller.go index a3558b6e4508..5b2ca8fbb21a 100644 --- a/pkg/controllers/multiclusterservice/mcs_controller.go +++ b/pkg/controllers/multiclusterservice/mcs_controller.go @@ -404,7 +404,12 @@ func (c *MCSController) propagateService(ctx context.Context, mcs *networkingv1a bindingCopy.Spec.Placement = binding.Spec.Placement bindingCopy.Spec.Resource = binding.Spec.Resource bindingCopy.Spec.ConflictResolution = binding.Spec.ConflictResolution - bindingCopy.Spec.Suspension = binding.Spec.Suspension + if binding.Spec.Suspension != nil { + if bindingCopy.Spec.Suspension == nil { + bindingCopy.Spec.Suspension = &workv1alpha2.Suspension{} + } + bindingCopy.Spec.Suspension.Suspension = binding.Spec.Suspension.Suspension + } return nil }) if err != nil { diff --git a/pkg/detector/detector.go b/pkg/detector/detector.go index 734b20ddfbbd..9d9cb0189614 100644 --- a/pkg/detector/detector.go +++ b/pkg/detector/detector.go @@ -476,8 +476,13 @@ func (d *ResourceDetector) ApplyPolicy(object *unstructured.Unstructured, object bindingCopy.Spec.Placement = binding.Spec.Placement bindingCopy.Spec.Failover = binding.Spec.Failover bindingCopy.Spec.ConflictResolution = binding.Spec.ConflictResolution - bindingCopy.Spec.Suspension = binding.Spec.Suspension bindingCopy.Spec.PreserveResourcesOnDeletion = binding.Spec.PreserveResourcesOnDeletion + if binding.Spec.Suspension != nil { + if bindingCopy.Spec.Suspension == nil { + bindingCopy.Spec.Suspension = &workv1alpha2.Suspension{} + } + bindingCopy.Spec.Suspension.Suspension = binding.Spec.Suspension.Suspension + } excludeClusterPolicy(bindingCopy) return nil }) @@ -565,8 +570,13 @@ func (d *ResourceDetector) ApplyClusterPolicy(object *unstructured.Unstructured, bindingCopy.Spec.Placement = binding.Spec.Placement bindingCopy.Spec.Failover = binding.Spec.Failover bindingCopy.Spec.ConflictResolution = binding.Spec.ConflictResolution - bindingCopy.Spec.Suspension = binding.Spec.Suspension bindingCopy.Spec.PreserveResourcesOnDeletion = binding.Spec.PreserveResourcesOnDeletion + if binding.Spec.Suspension != nil { + if bindingCopy.Spec.Suspension == nil { + bindingCopy.Spec.Suspension = &workv1alpha2.Suspension{} + } + bindingCopy.Spec.Suspension.Suspension = binding.Spec.Suspension.Suspension + } return nil }) return err @@ -612,8 +622,13 @@ func (d *ResourceDetector) ApplyClusterPolicy(object *unstructured.Unstructured, bindingCopy.Spec.Placement = binding.Spec.Placement bindingCopy.Spec.Failover = binding.Spec.Failover bindingCopy.Spec.ConflictResolution = binding.Spec.ConflictResolution - bindingCopy.Spec.Suspension = binding.Spec.Suspension bindingCopy.Spec.PreserveResourcesOnDeletion = binding.Spec.PreserveResourcesOnDeletion + if binding.Spec.Suspension != nil { + if bindingCopy.Spec.Suspension == nil { + bindingCopy.Spec.Suspension = &workv1alpha2.Suspension{} + } + bindingCopy.Spec.Suspension.Suspension = binding.Spec.Suspension.Suspension + } return nil }) return err