@@ -90,16 +90,20 @@ func parseDropPolicy(dropPolicy *v3endpointpb.ClusterLoadAssignment_Policy_DropO
90
90
}
91
91
}
92
92
93
- func parseEndpoints (lbEndpoints []* v3endpointpb.LbEndpoint ) []Endpoint {
93
+ func parseEndpoints (lbEndpoints []* v3endpointpb.LbEndpoint ) ( []Endpoint , error ) {
94
94
endpoints := make ([]Endpoint , 0 , len (lbEndpoints ))
95
95
for _ , lbEndpoint := range lbEndpoints {
96
+ weight := lbEndpoint .GetLoadBalancingWeight ().GetValue ()
97
+ if weight == 0 {
98
+ return nil , fmt .Errorf ("EDS response contains an endpoint with zero weight: %+v" , lbEndpoint )
99
+ }
96
100
endpoints = append (endpoints , Endpoint {
97
101
HealthStatus : EndpointHealthStatus (lbEndpoint .GetHealthStatus ()),
98
102
Address : parseAddress (lbEndpoint .GetEndpoint ().GetAddress ().GetSocketAddress ()),
99
- Weight : lbEndpoint . GetLoadBalancingWeight (). GetValue () ,
103
+ Weight : weight ,
100
104
})
101
105
}
102
- return endpoints
106
+ return endpoints , nil
103
107
}
104
108
105
109
func parseEDSRespProto (m * v3endpointpb.ClusterLoadAssignment , logger * grpclog.PrefixLogger ) (EndpointsUpdate , error ) {
@@ -134,9 +138,13 @@ func parseEDSRespProto(m *v3endpointpb.ClusterLoadAssignment, logger *grpclog.Pr
134
138
return EndpointsUpdate {}, fmt .Errorf ("duplicate locality %s with the same priority %v" , lidStr , priority )
135
139
}
136
140
localitiesWithPriority [lidStr ] = true
141
+ endpoints , err := parseEndpoints (locality .GetLbEndpoints ())
142
+ if err != nil {
143
+ return EndpointsUpdate {}, err
144
+ }
137
145
ret .Localities = append (ret .Localities , Locality {
138
146
ID : lid ,
139
- Endpoints : parseEndpoints ( locality . GetLbEndpoints ()) ,
147
+ Endpoints : endpoints ,
140
148
Weight : locality .GetLoadBalancingWeight ().GetValue (),
141
149
Priority : priority ,
142
150
})
0 commit comments