Skip to content

Commit 709cefa

Browse files
[Cherry-pick] fix: Do not add request-termination on TLSRoute / TCPRoute (#7700) (#7720) (#7730)
* fix: Do not add request-termination on TLSRoute / TCPRoute * fix: add import of strings and check nil * fix unit tests and golden test cases * add changelog --------- Co-authored-by: Victor Durand <[email protected]>
1 parent b549c90 commit 709cefa

File tree

9 files changed

+47
-45
lines changed

9 files changed

+47
-45
lines changed

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Adding a new version? You'll need three changes:
77
* Add the diff link, like "[2.7.0]: https://github.com/kong/kubernetes-ingress-controller/compare/v1.2.2...v1.2.3".
88
This is all the way at the bottom. It's the thing we always forget.
99
--->
10+
- [3.4.8](#348)
11+
- [3.4.7](#347)
1012
- [3.4.6](#346)
1113
- [3.4.5](#345)
1214
- [3.4.4](#344)
@@ -110,6 +112,36 @@ Adding a new version? You'll need three changes:
110112

111113
### Fixed
112114

115+
- Add `request-termination` plugin to return `500` if there are no available
116+
`backendRef` only when the service is translated from `HTTPRoute` or
117+
`GRPCRoute`.
118+
[#7720](https://github.com/Kong/kubernetes-ingress-controller/pull/7720)
119+
120+
## [3.4.8]
121+
122+
> Release date: 2025-07-10
123+
124+
### Fixes
125+
126+
- Fix `KongUpstreamPolicy` hash on translation.
127+
Until this version, when users specify cookie as hash fallback the rules
128+
are not translated correctly due to unusual field usage in kong upstream
129+
(and `KongUpstreamPolicy`'s `KongUpstreamHash`):
130+
cookie and cookie path is used both for `hash_on` and `hash_fallback` in
131+
kong upstream but not in `KongUpstreamHash` `KongUpstreamPolicy` so special care
132+
needs to be taken during translation.
133+
This is now fixed and users can use `hash_on` and `hash_fallback` as described
134+
in <https://developer.konghq.com/gateway/entities/upstream/#consistent-hashing>.
135+
[#7590](https://github.com/Kong/kubernetes-ingress-controller/pull/7590)
136+
- Bump Go to 1.24.5
137+
[#7600](https://github.com/Kong/kubernetes-ingress-controller/pull/7600)
138+
139+
## [3.4.7]
140+
141+
> Release date: 2025-06-20
142+
143+
### Fixed
144+
113145
- Count the `attachedRoutes` of a `Gateway` in the correct way in case of `HTTPRoute`s
114146
with multiple parent references.
115147
[#7517](https://github.com/Kong/kubernetes-ingress-controller/pull/7517)
@@ -4080,6 +4112,8 @@ Please read the changelog and test in your environment.
40804112
- The initial versions were rapildy iterated to deliver
40814113
a working ingress controller.
40824114

4115+
[3.4.6]: https://github.com/kong/kubernetes-ingress-controller/compare/v3.4.7...v3.4.8
4116+
[3.4.5]: https://github.com/kong/kubernetes-ingress-controller/compare/v3.4.6...v3.4.7
40834117
[3.4.6]: https://github.com/kong/kubernetes-ingress-controller/compare/v3.4.5...v3.4.6
40844118
[3.4.5]: https://github.com/kong/kubernetes-ingress-controller/compare/v3.4.4...v3.4.5
40854119
[3.4.4]: https://github.com/kong/kubernetes-ingress-controller/compare/v3.4.3...v3.4.4

internal/dataplane/testdata/golden/tcproute-example/default_golden.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ services:
44
host: tcproute.tcp-namespace.echo-plaintext.0
55
id: e2302e1e-0a75-5174-82f3-c0bc379a108a
66
name: tcproute.tcp-namespace.echo-plaintext.0
7-
plugins:
8-
- config:
9-
message: no existing backendRef provided
10-
status_code: 500
11-
name: request-termination
127
protocol: tcp
138
read_timeout: 60000
149
retries: 5

internal/dataplane/testdata/golden/tcproute-example/expression-routes-on_golden.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ services:
44
host: tcproute.tcp-namespace.echo-plaintext.0
55
id: e2302e1e-0a75-5174-82f3-c0bc379a108a
66
name: tcproute.tcp-namespace.echo-plaintext.0
7-
plugins:
8-
- config:
9-
message: no existing backendRef provided
10-
status_code: 500
11-
name: request-termination
127
protocol: tcp
138
read_timeout: 60000
149
retries: 5

internal/dataplane/testdata/golden/tlsroute-example/default_golden.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ services:
44
host: tlsroute.tls-namespace.echo-tls.0
55
id: 2a2aad7c-6331-5bcf-bd7c-d9516639f65d
66
name: tlsroute.tls-namespace.echo-tls.0
7-
plugins:
8-
- config:
9-
message: no existing backendRef provided
10-
status_code: 500
11-
name: request-termination
127
protocol: tcp
138
read_timeout: 60000
149
retries: 5

internal/dataplane/testdata/golden/tlsroute-example/expression-routes-on_golden.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ services:
44
host: tlsroute.tls-namespace.echo-tls.0
55
id: 2a2aad7c-6331-5bcf-bd7c-d9516639f65d
66
name: tlsroute.tls-namespace.echo-tls.0
7-
plugins:
8-
- config:
9-
message: no existing backendRef provided
10-
status_code: 500
11-
name: request-termination
127
protocol: tcp
138
read_timeout: 60000
149
retries: 5

internal/dataplane/testdata/golden/udproute-example/default_golden.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ services:
44
host: udproute.udp-example.tftp.0
55
id: 439fc57a-baff-51a3-9e1f-4e6af6b9dcae
66
name: udproute.udp-example.tftp.0
7-
plugins:
8-
- config:
9-
message: no existing backendRef provided
10-
status_code: 500
11-
name: request-termination
127
protocol: udp
138
read_timeout: 60000
149
retries: 5

internal/dataplane/testdata/golden/udproute-example/expression-routes-on_golden.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ services:
44
host: udproute.udp-example.tftp.0
55
id: 439fc57a-baff-51a3-9e1f-4e6af6b9dcae
66
name: udproute.udp-example.tftp.0
7-
plugins:
8-
- config:
9-
message: no existing backendRef provided
10-
status_code: 500
11-
name: request-termination
127
protocol: udp
138
read_timeout: 60000
149
retries: 5

internal/dataplane/translator/translate_utils.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package translator
22

33
import (
44
"fmt"
5+
"strings"
56

67
"github.com/go-logr/logr"
78
"github.com/kong/go-kong/kong"
@@ -79,13 +80,16 @@ func generateKongServiceFromBackendRefWithName(
7980
if service.Plugins == nil {
8081
service.Plugins = make([]kong.Plugin, 0)
8182
}
82-
service.Plugins = append(service.Plugins, kong.Plugin{
83-
Name: kong.String("request-termination"),
84-
Config: kong.Configuration{
85-
"status_code": 500,
86-
"message": "no existing backendRef provided",
87-
},
88-
})
83+
if service.Protocol != nil &&
84+
(strings.Contains(*service.Protocol, "http") || strings.Contains(*service.Protocol, "grpc")) {
85+
service.Plugins = append(service.Plugins, kong.Plugin{
86+
Name: kong.String("request-termination"),
87+
Config: kong.Configuration{
88+
"status_code": 500,
89+
"message": "no existing backendRef provided",
90+
},
91+
})
92+
}
8993
}
9094

9195
return service, nil

internal/dataplane/translator/translate_utils_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,8 @@ func TestGenerateKongServiceFromBackendRef(t *testing.T) {
290290
},
291291
Namespace: "behbudiy",
292292
Backends: []kongstate.ServiceBackend{},
293-
Plugins: []kong.Plugin{
294-
{
295-
Name: kong.String("request-termination"),
296-
Config: kong.Configuration{
297-
"status_code": 500,
298-
"message": "no existing backendRef provided",
299-
},
300-
},
293+
Plugins: []kong.Plugin{
294+
// No request-termination plugin is added for services with protocol not containing `http` or `grpc`.
301295
},
302296
Parent: &gatewayapi.TCPRoute{
303297
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)