TopologyAwareHints: fix getHintsByZone bug

The bug could result in the EndpointSlice controller unnecessarily updating
EndpointSlices associated with a Service that had Topology Aware Hints enabled.
This commit is contained in:
llhuii 2021-09-27 16:04:36 +08:00
parent d385d0602a
commit 528cd30145

View File

@ -188,9 +188,13 @@ func getHintsByZone(slice *discovery.EndpointSlice, allocatedHintsByZone Endpoin
if endpoint.Hints == nil || len(endpoint.Hints.ForZones) == 0 { if endpoint.Hints == nil || len(endpoint.Hints.ForZones) == 0 {
return nil return nil
} }
zone := endpoint.Hints.ForZones[0].Name
if _, ok := allocations[zone]; ok { for i := range endpoint.Hints.ForZones {
return nil zone := endpoint.Hints.ForZones[i].Name
if _, ok := allocations[zone]; !ok {
return nil
}
hintsByZone[zone]++
} }
} }