mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-08-08 23:37:11 +00:00
Don't log irrelevant zone hints message on no endpoints
Update pkg/proxy/topology.go Co-authored-by: Dan Winship <danwinship@redhat.com> Add unit test case
This commit is contained in:
@@ -153,6 +153,12 @@ func CategorizeEndpoints(endpoints []Endpoint, svcInfo ServicePort, nodeName str
|
||||
// hinted for this node's zone, then it returns "PreferSameZone".
|
||||
// - Otherwise it returns "" (meaning, no topology / default traffic distribution).
|
||||
func topologyModeFromHints(svcInfo ServicePort, endpoints []Endpoint, nodeName, zone string) string {
|
||||
if len(endpoints) == 0 {
|
||||
// The code below assumes at least 1 endpoint; if there are no endpoints,
|
||||
// there are no hints.
|
||||
return ""
|
||||
}
|
||||
|
||||
hasEndpointForNode := false
|
||||
allEndpointsHaveNodeHints := true
|
||||
hasEndpointForZone := false
|
||||
|
||||
@@ -390,6 +390,13 @@ func TestCategorizeEndpoints(t *testing.T) {
|
||||
clusterEndpoints: nil,
|
||||
localEndpoints: sets.New[string]("10.0.0.1:80"),
|
||||
allEndpoints: sets.New[string]("10.0.0.1:80"),
|
||||
}, {
|
||||
name: "empty cluster endpoints when no service endpoints exist",
|
||||
serviceInfo: &BaseServicePortInfo{},
|
||||
endpoints: nil,
|
||||
clusterEndpoints: sets.New[string](),
|
||||
localEndpoints: nil,
|
||||
allEndpoints: nil,
|
||||
}}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user