mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-18 16:21:13 +00:00
pkg/proxy: update CategorizeEndpoints to apply ProxyTerminatingEndpoints to all traffic policies
Signed-off-by: Andrew Sy Kim <andrewsy@google.com>
This commit is contained in:
parent
c64a8cdc2d
commit
e2e0b6fca8
@ -52,6 +52,19 @@ func CategorizeEndpoints(endpoints []Endpoint, svcInfo ServicePort, nodeLabels m
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// if there are 0 cluster-wide endpoints, we can try to fallback to any terminating endpoints that are ready.
|
||||||
|
// When falling back to terminating endpoints, we do NOT consider topology aware routing since this is a best
|
||||||
|
// effort attempt to avoid dropping connections.
|
||||||
|
if len(clusterEndpoints) == 0 && utilfeature.DefaultFeatureGate.Enabled(features.ProxyTerminatingEndpoints) {
|
||||||
|
clusterEndpoints = filterEndpoints(endpoints, func(ep Endpoint) bool {
|
||||||
|
if ep.IsServing() && ep.IsTerminating() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// If there are any Ready endpoints anywhere in the cluster, we are
|
// If there are any Ready endpoints anywhere in the cluster, we are
|
||||||
// guaranteed to get one in clusterEndpoints.
|
// guaranteed to get one in clusterEndpoints.
|
||||||
if len(clusterEndpoints) > 0 {
|
if len(clusterEndpoints) > 0 {
|
||||||
|
@ -350,7 +350,17 @@ func TestCategorizeEndpoints(t *testing.T) {
|
|||||||
serviceInfo: &BaseServiceInfo{},
|
serviceInfo: &BaseServiceInfo{},
|
||||||
endpoints: []Endpoint{
|
endpoints: []Endpoint{
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.0.0:80", Ready: false, Serving: true, Terminating: true, IsLocal: true},
|
&BaseEndpointInfo{Endpoint: "10.0.0.0:80", Ready: false, Serving: true, Terminating: true, IsLocal: true},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.0.1:80", Ready: false, Serving: true, Terminating: true, IsLocal: true},
|
&BaseEndpointInfo{Endpoint: "10.0.0.1:80", Ready: false, Serving: true, Terminating: true, IsLocal: false},
|
||||||
|
},
|
||||||
|
clusterEndpoints: sets.NewString("10.0.0.0:80", "10.0.0.1:80"),
|
||||||
|
localEndpoints: nil,
|
||||||
|
}, {
|
||||||
|
name: "Cluster traffic policy, PTE disabled, all endpoints are terminating",
|
||||||
|
pteEnabled: false,
|
||||||
|
serviceInfo: &BaseServiceInfo{},
|
||||||
|
endpoints: []Endpoint{
|
||||||
|
&BaseEndpointInfo{Endpoint: "10.0.0.0:80", Ready: false, Serving: true, Terminating: true, IsLocal: true},
|
||||||
|
&BaseEndpointInfo{Endpoint: "10.0.0.1:80", Ready: false, Serving: true, Terminating: true, IsLocal: false},
|
||||||
},
|
},
|
||||||
clusterEndpoints: sets.NewString(),
|
clusterEndpoints: sets.NewString(),
|
||||||
localEndpoints: nil,
|
localEndpoints: nil,
|
||||||
@ -412,9 +422,9 @@ func TestCategorizeEndpoints(t *testing.T) {
|
|||||||
&BaseEndpointInfo{Endpoint: "10.0.0.0:80", Ready: false, Serving: true, Terminating: true, IsLocal: false},
|
&BaseEndpointInfo{Endpoint: "10.0.0.0:80", Ready: false, Serving: true, Terminating: true, IsLocal: false},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.0.1:80", Ready: false, Serving: true, Terminating: true, IsLocal: false},
|
&BaseEndpointInfo{Endpoint: "10.0.0.1:80", Ready: false, Serving: true, Terminating: true, IsLocal: false},
|
||||||
},
|
},
|
||||||
clusterEndpoints: sets.NewString(),
|
clusterEndpoints: sets.NewString("10.0.0.0:80", "10.0.0.1:80"),
|
||||||
localEndpoints: sets.NewString(),
|
localEndpoints: sets.NewString(),
|
||||||
allEndpoints: sets.NewString(),
|
allEndpoints: sets.NewString("10.0.0.0:80", "10.0.0.1:80"),
|
||||||
onlyRemoteEndpoints: true,
|
onlyRemoteEndpoints: true,
|
||||||
}, {
|
}, {
|
||||||
name: "iTP: Cluster, eTP: Local, PTE disabled, with terminating endpoints",
|
name: "iTP: Cluster, eTP: Local, PTE disabled, with terminating endpoints",
|
||||||
|
Loading…
Reference in New Issue
Block a user