@@ -26,15 +26,19 @@ import (
26
26
// - The service's usable Cluster-traffic-policy endpoints (taking topology into account, if
27
27
// relevant). This will be nil if the service does not ever use Cluster traffic policy.
28
28
//
29
- // - The service's usable Local-traffic-policy endpoints (including terminating endpoints, if
30
- // relevant). This will be nil if the service does not ever use Local traffic policy.
29
+ // - The service's usable Local-traffic-policy endpoints. This will be nil if the
30
+ // service does not ever use Local traffic policy.
31
31
//
32
32
// - The combined list of all endpoints reachable from this node (which is the union of the
33
33
// previous two lists, but in the case where it is identical to one or the other, we avoid
34
34
// allocating a separate list).
35
35
//
36
36
// - An indication of whether the service has any endpoints reachable from anywhere in the
37
37
// cluster. (This may be true even if allReachableEndpoints is empty.)
38
+ //
39
+ // "Usable endpoints" means Ready endpoints by default, but will fall back to
40
+ // Serving-Terminating endpoints (independently for Cluster and Local) if no Ready
41
+ // endpoints are available.
38
42
func CategorizeEndpoints (endpoints []Endpoint , svcInfo ServicePort , nodeLabels map [string ]string ) (clusterEndpoints , localEndpoints , allReachableEndpoints []Endpoint , hasAnyEndpoints bool ) {
39
43
var useTopology , useServingTerminatingEndpoints bool
40
44
@@ -50,9 +54,10 @@ func CategorizeEndpoints(endpoints []Endpoint, svcInfo ServicePort, nodeLabels m
50
54
return true
51
55
})
52
56
53
- // if there are 0 cluster-wide endpoints, we can try to fallback to any terminating endpoints that are ready.
54
- // When falling back to terminating endpoints, we do NOT consider topology aware routing since this is a best
55
- // effort attempt to avoid dropping connections.
57
+ // If we didn't get any endpoints, try again using terminating endpoints.
58
+ // (Note that we would already have chosen to ignore topology if there
59
+ // were no ready endpoints for the given topology, so the problem at this
60
+ // point must be that there are no ready endpoints anywhere.)
56
61
if len (clusterEndpoints ) == 0 {
57
62
clusterEndpoints = filterEndpoints (endpoints , func (ep Endpoint ) bool {
58
63
if ep .IsServing () && ep .IsTerminating () {
0 commit comments