@@ -160,19 +160,23 @@ func canUseTopology(endpoints []Endpoint, svcInfo ServicePort, nodeLabels map[st
160
160
}
161
161
}
162
162
163
- zone , ok := nodeLabels [v1 .LabelTopologyZone ]
164
- if ! ok || zone == "" {
165
- klog .V (2 ).InfoS ("Skipping topology aware endpoint filtering since node is missing label" , "label" , v1 .LabelTopologyZone )
166
- return false
167
- }
168
-
163
+ zone , foundZone := nodeLabels [v1 .LabelTopologyZone ]
169
164
hasEndpointForZone := false
170
165
for _ , endpoint := range endpoints {
171
166
if ! endpoint .IsReady () {
172
167
continue
173
168
}
169
+
170
+ // If any of the endpoints do not have zone hints, we bail out
174
171
if endpoint .ZoneHints ().Len () == 0 {
175
- klog .V (2 ).InfoS ("Skipping topology aware endpoint filtering since one or more endpoints is missing a zone hint" , "endpoint" , endpoint )
172
+ klog .V (7 ).InfoS ("Skipping topology aware endpoint filtering since one or more endpoints is missing a zone hint" , "endpoint" , endpoint )
173
+ return false
174
+ }
175
+
176
+ // If we've made it this far, we have endpoints with hints set. Now we check if there is a
177
+ // zone label, if there isn't one we log a warning and bail out
178
+ if ! foundZone || zone == "" {
179
+ klog .V (2 ).InfoS ("Skipping topology aware endpoint filtering since node is missing label" , "label" , v1 .LabelTopologyZone )
176
180
return false
177
181
}
178
182
@@ -182,10 +186,9 @@ func canUseTopology(endpoints []Endpoint, svcInfo ServicePort, nodeLabels map[st
182
186
}
183
187
184
188
if ! hasEndpointForZone {
185
- klog .V (2 ).InfoS ("Skipping topology aware endpoint filtering since no hints were provided for zone" , "zone" , zone )
189
+ klog .V (7 ).InfoS ("Skipping topology aware endpoint filtering since no hints were provided for zone" , "zone" , zone )
186
190
return false
187
191
}
188
-
189
192
return true
190
193
}
191
194
0 commit comments