From 3d65332f60359b0a7750e0dbc34a957d213f9eb8 Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 6 Nov 2024 21:23:33 +0800 Subject: [PATCH] fix(affinity): fixed the logic to extract affinities --- internal/dashboard/business/oceanbase/obcluster.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/dashboard/business/oceanbase/obcluster.go b/internal/dashboard/business/oceanbase/obcluster.go index 5548446f..7a711fe8 100644 --- a/internal/dashboard/business/oceanbase/obcluster.go +++ b/internal/dashboard/business/oceanbase/obcluster.go @@ -203,8 +203,7 @@ func buildOBClusterTopologyResp(ctx context.Context, obcluster *v1alpha1.OBClust affinities := make([]modelcommon.AffinitySpec, 0) if obzone.Spec.Topology.Affinity != nil { zoneAffinity := obzone.Spec.Topology.Affinity - switch { - case zoneAffinity.NodeAffinity != nil: + if zoneAffinity.NodeAffinity != nil { zn := zoneAffinity.NodeAffinity if zn.RequiredDuringSchedulingIgnoredDuringExecution != nil { for _, term := range zn.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms { @@ -234,7 +233,8 @@ func buildOBClusterTopologyResp(ctx context.Context, obcluster *v1alpha1.OBClust }) } } - case zoneAffinity.PodAffinity != nil: + } + if zoneAffinity.PodAffinity != nil { zp := zoneAffinity.PodAffinity for _, term := range zp.RequiredDuringSchedulingIgnoredDuringExecution { for _, req := range term.LabelSelector.MatchExpressions { @@ -262,7 +262,8 @@ func buildOBClusterTopologyResp(ctx context.Context, obcluster *v1alpha1.OBClust }) } } - case zoneAffinity.PodAntiAffinity != nil: + } + if zoneAffinity.PodAntiAffinity != nil { zpa := zoneAffinity.PodAntiAffinity for _, term := range zpa.RequiredDuringSchedulingIgnoredDuringExecution { for _, req := range term.LabelSelector.MatchExpressions {