Skip to content

Commit

Permalink
lbType should not be null for new services
Browse files Browse the repository at this point in the history
Signed-off-by: Shriram Sharma <[email protected]>
  • Loading branch information
adilfulara authored and shriramsharma committed Aug 9, 2024
1 parent 6c0ab62 commit 2818580
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions admiral/pkg/clusters/serviceentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion admiral/pkg/clusters/serviceentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
}
})
}
Expand Down

0 comments on commit 2818580

Please sign in to comment.