From 528cd3014544c9ae7f97fa5315fe10f069e57f48 Mon Sep 17 00:00:00 2001 From: llhuii Date: Mon, 27 Sep 2021 16:04:36 +0800 Subject: [PATCH] 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. --- pkg/controller/endpointslice/topologycache/utils.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/controller/endpointslice/topologycache/utils.go b/pkg/controller/endpointslice/topologycache/utils.go index d5a6f0b9bc8..cb9dc3cee91 100644 --- a/pkg/controller/endpointslice/topologycache/utils.go +++ b/pkg/controller/endpointslice/topologycache/utils.go @@ -188,9 +188,13 @@ func getHintsByZone(slice *discovery.EndpointSlice, allocatedHintsByZone Endpoin if endpoint.Hints == nil || len(endpoint.Hints.ForZones) == 0 { return nil } - zone := endpoint.Hints.ForZones[0].Name - if _, ok := allocations[zone]; ok { - return nil + + for i := range endpoint.Hints.ForZones { + zone := endpoint.Hints.ForZones[i].Name + if _, ok := allocations[zone]; !ok { + return nil + } + hintsByZone[zone]++ } }