Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xdsclient: NACK endpoint resource if load_balancing_weight is specified and is zero #5568

Merged
merged 1 commit into from Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion internal/testutils/xds/e2e/clientresources.go
Expand Up @@ -370,7 +370,6 @@ func DefaultEndpoint(clusterName string, host string, ports []uint32) *v3endpoin
PortSpecifier: &v3corepb.SocketAddress_PortValue{PortValue: port}},
}},
}},
LoadBalancingWeight: &wrapperspb.UInt32Value{Value: 1},
})
}
return &v3endpointpb.ClusterLoadAssignment{
Expand Down
3 changes: 0 additions & 3 deletions xds/internal/testutils/protos.go
Expand Up @@ -118,9 +118,6 @@ func (clab *ClusterLoadAssignmentBuilder) AddLocality(subzone string, weight uin
lbe.LoadBalancingWeight = &wrapperspb.UInt32Value{Value: opts.Weight[i]}
}
}
if lbe.LoadBalancingWeight == nil {
lbe.LoadBalancingWeight = &wrapperspb.UInt32Value{Value: 1}
}
lbEndPoints = append(lbEndPoints, lbe)
}

Expand Down
12 changes: 9 additions & 3 deletions xds/internal/xdsclient/xdsresource/unmarshal_eds.go
Expand Up @@ -93,9 +93,15 @@ func parseDropPolicy(dropPolicy *v3endpointpb.ClusterLoadAssignment_Policy_DropO
func parseEndpoints(lbEndpoints []*v3endpointpb.LbEndpoint) ([]Endpoint, error) {
endpoints := make([]Endpoint, 0, len(lbEndpoints))
for _, lbEndpoint := range lbEndpoints {
weight := lbEndpoint.GetLoadBalancingWeight().GetValue()
if weight == 0 {
return nil, fmt.Errorf("EDS response contains an endpoint with zero weight: %+v", lbEndpoint)
// If the load_balancing_weight field is specified, it must be set to a
// value of at least 1. If unspecified, each host is presumed to have
// equal weight in a locality.
weight := uint32(1)
if w := lbEndpoint.GetLoadBalancingWeight(); w != nil {
if w.GetValue() == 0 {
return nil, fmt.Errorf("EDS response contains an endpoint with zero weight: %+v", lbEndpoint)
}
weight = w.GetValue()
}
endpoints = append(endpoints, Endpoint{
HealthStatus: EndpointHealthStatus(lbEndpoint.GetHealthStatus()),
Expand Down