From 28185808a396fdfd02149d7bd4ffd7faa373ab1c Mon Sep 17 00:00:00 2001 From: adilfulara Date: Fri, 9 Aug 2024 11:00:53 -0700 Subject: [PATCH] lbType should not be null for new services Signed-off-by: Shriram Sharma --- admiral/pkg/clusters/serviceentry.go | 1 + admiral/pkg/clusters/serviceentry_test.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/admiral/pkg/clusters/serviceentry.go b/admiral/pkg/clusters/serviceentry.go index 9594645b..e4af10dd 100644 --- a/admiral/pkg/clusters/serviceentry.go +++ b/admiral/pkg/clusters/serviceentry.go @@ -1599,6 +1599,7 @@ func getWorkloadData(ctxLogger *logrus.Entry, serviceEntry *v1alpha3.ServiceEntr dr.TrafficPolicy.LoadBalancer.LocalityLbSetting.Distribute[0].From == "*" { for region, weight := range dr.TrafficPolicy.LoadBalancer.LocalityLbSetting.Distribute[0].To { trafficDistribution[region] = int32(weight) + lbType = model.TrafficPolicy_LbType_name[int32(model.TrafficPolicy_FAILOVER)] } } } diff --git a/admiral/pkg/clusters/serviceentry_test.go b/admiral/pkg/clusters/serviceentry_test.go index 767bfaa7..775de37c 100644 --- a/admiral/pkg/clusters/serviceentry_test.go +++ b/admiral/pkg/clusters/serviceentry_test.go @@ -5959,6 +5959,7 @@ func TestGetWorkloadDataActivePassiveEnabled(t *testing.T) { Env: "dev", Aliases: []string{"dev.custom.testsuffix"}, TrafficDistribution: map[string]int32{"us-west-2": 100}, + LbType: model.TrafficPolicy_LbType_name[int32(model.TrafficPolicy_FAILOVER)], } var workloadDataWithFailoverGTP = WorkloadData{ @@ -6100,7 +6101,7 @@ func TestGetWorkloadDataActivePassiveEnabled(t *testing.T) { t.Run(c.name, func(t *testing.T) { workloadData := getWorkloadData(ctxLogger, c.serviceEntry, c.globalTrafficPolicy, c.additionalEndpoints, c.dr, "dev", c.isSuccess) if !reflect.DeepEqual(workloadData, c.expectedWorkloadData) { - assert.Fail(t, "actual and expected workload data do not match. Actual : %v. Expected : %v.", workloadData, c.expectedWorkloadData) + assert.Fail(t, "actual and expected workload data do not match.", "Actual : %v. Expected : %v.", workloadData, c.expectedWorkloadData) } }) }