Skip to content

Commit

Permalink
Fix hint annotation implementation in AntreaProxy (#6607)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
hongliangl committed Aug 14, 2024
1 parent 254b5ce commit 7d8d4b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions pkg/agent/proxy/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,9 @@ func (p *proxier) canUseTopology(endpoints map[string]k8sproxy.Endpoint, svcInfo
if !p.topologyAwareHintsEnabled {
return false
}
// Any non-empty and non-disabled values for the hints annotation are acceptable.
hintsAnnotation := svcInfo.HintsAnnotation()
if hintsAnnotation != "Auto" && hintsAnnotation != "auto" {
if hintsAnnotation != "" && hintsAnnotation != "Disabled" && hintsAnnotation != "disabled" {
klog.InfoS("Skipping topology aware Endpoint filtering since Service has unexpected value", "annotationTopologyAwareHints", v1.DeprecatedAnnotationTopologyAwareHints, "hints", hintsAnnotation)
}
if hintsAnnotation == "" || hintsAnnotation == "disabled" || hintsAnnotation == "Disabled" {
return false
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/proxy/topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestCategorizeEndpoints(t *testing.T) {
localEndpoints: nil,
},
{
name: "hints enabled, hints annotation == aUto (wrong capitalization), hints ignored",
name: "hints enabled, hints annotation == aUto (wrong capitalization), hints no longer ignored",
hintsEnabled: true,
nodeLabels: map[string]string{v1.LabelTopologyZone: "zone-a"},
serviceInfo: k8sproxy.NewBaseServiceInfo(net.ParseIP("10.96.0.1"), 80, v1.ProtocolTCP, 0, nil, "", 0, nil, nil, 0, false, false, nil, "aUto"),
Expand All @@ -107,7 +107,7 @@ func TestCategorizeEndpoints(t *testing.T) {
"10.1.2.5:80": &k8sproxy.BaseEndpointInfo{Endpoint: "10.1.2.5:80", ZoneHints: sets.New[string]("zone-c"), Ready: true},
"10.1.2.6:80": &k8sproxy.BaseEndpointInfo{Endpoint: "10.1.2.6:80", ZoneHints: sets.New[string]("zone-a"), Ready: true},
},
clusterEndpoints: sets.New[string]("10.1.2.3:80", "10.1.2.4:80", "10.1.2.5:80", "10.1.2.6:80"),
clusterEndpoints: sets.New[string]("10.1.2.3:80", "10.1.2.6:80"),
localEndpoints: nil,
},
{
Expand Down

0 comments on commit 7d8d4b1

Please sign in to comment.