Skip to content

Commit 7d8d4b1

Browse files
authored
Fix hint annotation implementation in AntreaProxy (antrea-io#6607)
This commit is to be consistent with kube-proxy's behavior for Topology Aware Routing feature. For `service.kubernetes.io/topology-mode` hint annotation, any non-empty and non-disabled values for the annotation are acceptable to enable Topology Aware Routing for a Service. Signed-off-by: Hongliang Liu <[email protected]>
1 parent 254b5ce commit 7d8d4b1

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

pkg/agent/proxy/topology.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,9 @@ func (p *proxier) canUseTopology(endpoints map[string]k8sproxy.Endpoint, svcInfo
124124
if !p.topologyAwareHintsEnabled {
125125
return false
126126
}
127+
// Any non-empty and non-disabled values for the hints annotation are acceptable.
127128
hintsAnnotation := svcInfo.HintsAnnotation()
128-
if hintsAnnotation != "Auto" && hintsAnnotation != "auto" {
129-
if hintsAnnotation != "" && hintsAnnotation != "Disabled" && hintsAnnotation != "disabled" {
130-
klog.InfoS("Skipping topology aware Endpoint filtering since Service has unexpected value", "annotationTopologyAwareHints", v1.DeprecatedAnnotationTopologyAwareHints, "hints", hintsAnnotation)
131-
}
129+
if hintsAnnotation == "" || hintsAnnotation == "disabled" || hintsAnnotation == "Disabled" {
132130
return false
133131
}
134132

pkg/agent/proxy/topology_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestCategorizeEndpoints(t *testing.T) {
9797
localEndpoints: nil,
9898
},
9999
{
100-
name: "hints enabled, hints annotation == aUto (wrong capitalization), hints ignored",
100+
name: "hints enabled, hints annotation == aUto (wrong capitalization), hints no longer ignored",
101101
hintsEnabled: true,
102102
nodeLabels: map[string]string{v1.LabelTopologyZone: "zone-a"},
103103
serviceInfo: k8sproxy.NewBaseServiceInfo(net.ParseIP("10.96.0.1"), 80, v1.ProtocolTCP, 0, nil, "", 0, nil, nil, 0, false, false, nil, "aUto"),
@@ -107,7 +107,7 @@ func TestCategorizeEndpoints(t *testing.T) {
107107
"10.1.2.5:80": &k8sproxy.BaseEndpointInfo{Endpoint: "10.1.2.5:80", ZoneHints: sets.New[string]("zone-c"), Ready: true},
108108
"10.1.2.6:80": &k8sproxy.BaseEndpointInfo{Endpoint: "10.1.2.6:80", ZoneHints: sets.New[string]("zone-a"), Ready: true},
109109
},
110-
clusterEndpoints: sets.New[string]("10.1.2.3:80", "10.1.2.4:80", "10.1.2.5:80", "10.1.2.6:80"),
110+
clusterEndpoints: sets.New[string]("10.1.2.3:80", "10.1.2.6:80"),
111111
localEndpoints: nil,
112112
},
113113
{

0 commit comments

Comments
 (0)