Merge pull request #100728 from robscott/topology-auto
Updating Topology Aware Hints to support "Auto" value for annotation
This commit is contained in:
@@ -49,15 +49,15 @@ func FilterEndpoints(endpoints []Endpoint, svcInfo ServicePort, nodeLabels map[s
|
||||
// filterEndpointsWithHints provides filtering based on the hints included in
|
||||
// EndpointSlices. If any of the following are true, the full list of endpoints
|
||||
// will be returned without any filtering:
|
||||
// * The AnnotationTopologyAwareHints annotation is not set to "auto" for this
|
||||
// * The AnnotationTopologyAwareHints annotation is not set to "Auto" for this
|
||||
// Service.
|
||||
// * No zone is specified in node labels.
|
||||
// * No endpoints for this Service have a hint pointing to the zone this
|
||||
// instance of kube-proxy is running in.
|
||||
// * One or more endpoints for this Service do not have hints specified.
|
||||
func filterEndpointsWithHints(endpoints []Endpoint, hintsAnnotation string, nodeLabels map[string]string) []Endpoint {
|
||||
if hintsAnnotation != "auto" {
|
||||
if hintsAnnotation != "" && hintsAnnotation != "disabled" {
|
||||
if hintsAnnotation != "Auto" && hintsAnnotation != "auto" {
|
||||
if hintsAnnotation != "" && hintsAnnotation != "Disabled" && hintsAnnotation != "disabled" {
|
||||
klog.Warningf("Skipping topology aware endpoint filtering since Service has unexpected value for %s annotation: %s", v1.AnnotationTopologyAwareHints, hintsAnnotation)
|
||||
}
|
||||
return endpoints
|
||||
|
@@ -77,11 +77,11 @@ func TestFilterEndpoints(t *testing.T) {
|
||||
{ip: "10.1.2.6", zoneHints: sets.NewString("zone-a")},
|
||||
},
|
||||
}, {
|
||||
name: "hints + eps proxying enabled, hints annotation == Auto (wrong capitalization), hints ignored",
|
||||
name: "hints + eps proxying enabled, hints annotation == aUto (wrong capitalization), hints ignored",
|
||||
hintsEnabled: true,
|
||||
epsProxyingEnabled: true,
|
||||
nodeLabels: map[string]string{v1.LabelTopologyZone: "zone-a"},
|
||||
serviceInfo: &BaseServiceInfo{nodeLocalExternal: false, hintsAnnotation: "Auto"},
|
||||
serviceInfo: &BaseServiceInfo{nodeLocalExternal: false, hintsAnnotation: "aUto"},
|
||||
endpoints: []endpoint{
|
||||
{ip: "10.1.2.3", zoneHints: sets.NewString("zone-a")},
|
||||
{ip: "10.1.2.4", zoneHints: sets.NewString("zone-b")},
|
||||
@@ -234,7 +234,7 @@ func Test_filterEndpointsWithHints(t *testing.T) {
|
||||
endpoints: []endpoint{{ip: "10.1.2.3", zoneHints: sets.NewString("zone-a")}},
|
||||
expectedEndpoints: []endpoint{{ip: "10.1.2.3", zoneHints: sets.NewString("zone-a")}},
|
||||
}, {
|
||||
name: "normal endpoint filtering",
|
||||
name: "normal endpoint filtering, auto annotation",
|
||||
nodeLabels: map[string]string{v1.LabelTopologyZone: "zone-a"},
|
||||
hintsAnnotation: "auto",
|
||||
endpoints: []endpoint{
|
||||
@@ -247,6 +247,20 @@ func Test_filterEndpointsWithHints(t *testing.T) {
|
||||
{ip: "10.1.2.3", zoneHints: sets.NewString("zone-a")},
|
||||
{ip: "10.1.2.6", zoneHints: sets.NewString("zone-a")},
|
||||
},
|
||||
}, {
|
||||
name: "normal endpoint filtering, Auto annotation",
|
||||
nodeLabels: map[string]string{v1.LabelTopologyZone: "zone-a"},
|
||||
hintsAnnotation: "Auto",
|
||||
endpoints: []endpoint{
|
||||
{ip: "10.1.2.3", zoneHints: sets.NewString("zone-a")},
|
||||
{ip: "10.1.2.4", zoneHints: sets.NewString("zone-b")},
|
||||
{ip: "10.1.2.5", zoneHints: sets.NewString("zone-c")},
|
||||
{ip: "10.1.2.6", zoneHints: sets.NewString("zone-a")},
|
||||
},
|
||||
expectedEndpoints: []endpoint{
|
||||
{ip: "10.1.2.3", zoneHints: sets.NewString("zone-a")},
|
||||
{ip: "10.1.2.6", zoneHints: sets.NewString("zone-a")},
|
||||
},
|
||||
}, {
|
||||
name: "hintsAnnotation empty, no filtering applied",
|
||||
nodeLabels: map[string]string{v1.LabelTopologyZone: "zone-a"},
|
||||
|
Reference in New Issue
Block a user