Skip to content

Commit e55e154

Browse files
cnvergenceziraincodefromthecryptzhaohuabingdylanmtaylor
authored
[release/v1.7] cherry-pick for v1.7.0-rc.2 (#8165)
* e2e: speed tracing tests (#8124) * e2e: speed tracing tests Signed-off-by: zirain <zirain2009@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix(translator): allow single-label backends in host mode (#8123) Signed-off-by: Adrian Cole <adrian@tetrate.io> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * ci: release json report (#8107) Signed-off-by: zirain <zirain2009@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix oidc flakiness (#8119) * fix oidc flakiness Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix: skip_test_workflow doesn't exist (#8116) This also uses grouped redirects to satisfy shellcheck SC2129. Signed-off-by: Dylan M. Taylor <dylan@dylanmtaylor.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix e2e test panic (#8109) fix e2e test Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * chore: bump func-e to v1.4.0 (#8105) bump func-e to v1.4.0 Signed-off-by: Adrian Cole <adrian@tetrate.io> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix: route idle timeout (#8058) * fix: route idle timeout Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comments Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * add test Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * docs: add Mirakl to adopters list (#8138) Signed-off-by: Thierry Wandja <thierry.wandja@mirakl.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * docs: add security warning to control plane extensions (#7967) chore(docs): add warnings about control plane extensions Signed-off-by: Guy Daich <guy.daich@sap.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * chore: add lint for release notes filenames (#8137) * chore: add lint for release notes filenames Signed-off-by: zirain <zirain2009@gmail.com> * remove 1.7.0 Signed-off-by: zirain <zirain2009@gmail.com> * fix lint Signed-off-by: zirain <zirain2009@gmail.com> --------- Signed-off-by: zirain <zirain2009@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix: remove global logger in message package (#8131) * fix: remove global logger in message package Signed-off-by: zirain <zirain2009@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * docs: fix url result of regex rewrite (#7864) * Update http-urlrewrite.md Signed-off-by: Sadmi Bouhafs <sadmibouhafs@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * chore: log skipped xds (#8132) log skipped xds Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * docs: fixes for OPA sidecar + Unix Domain Socket task (#8142) Signed-off-by: Matt Miller <millermatt@outlook.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix: basic auth validation (#8053) * fix basic auth validation Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix: controller cache-sync readiness check (#7430) Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix: replace context.TODO with timeout context in config dump (#8122) * fix: replace context.TODO with timeout context in config dump Uses context.WithTimeout instead of context.TODO() to enable proper cancellation and prevent indefinite hangs when Kubernetes API is slow or unavailable. Fixes #8121 Signed-off-by: jaffar <keikei.jaffar@mail.utoronto.ca> * Make config dump timeout configurable with 30s default - Add Timeout field to ConfigDump struct - Add DefaultConfigDumpTimeout constant (30s) - Add getTimeout() helper that returns configured timeout or default - Update Collect() to use cd.getTimeout() instead of hardcoded value Signed-off-by: jaffar <keikei.jaffar@mail.utoronto.ca> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * refactor: convert IR map fields to slices to ensure deterministic Dee… (#7953) * refactor: convert IR map fields to slices to ensure deterministic DeepEqual Addresses issue #7852. Signed-off-by: Junnygram <junnexclusive@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix links in releasing and develop docs (#8141) * fix links in releasing and develop docs Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * update quickstart link Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> --------- Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * docs: add provider guide for entra (#7977) * docs: add provider guide for entra Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * chore: clean up test output files (#8154) clean up test output files Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix: TCPRoute mTLS didn't work (#8152) * fix: remove auto HTTP config on TCP cluster Signed-off-by: zirain <zirain2009@gmail.com> * fix lint Signed-off-by: zirain <zirain2009@gmail.com> * add e2e Signed-off-by: zirain <zirain2009@gmail.com> * fix e2e Signed-off-by: zirain <zirain2009@gmail.com> * fix comment Signed-off-by: zirain <zirain2009@gmail.com> * fix Signed-off-by: zirain <zirain2009@gmail.com> * fix resource name Signed-off-by: zirain <zirain2009@gmail.com> * address Arko's comment Signed-off-by: zirain <zirain2009@gmail.com> --------- Signed-off-by: zirain <zirain2009@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * v1.7.0-rc2 release notes (#8163) * v1.7.0-rc2 release notes Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * fix the date Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> --------- Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> --------- Signed-off-by: zirain <zirain2009@gmail.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> Signed-off-by: Adrian Cole <adrian@tetrate.io> Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Dylan M. Taylor <dylan@dylanmtaylor.com> Signed-off-by: Thierry Wandja <thierry.wandja@mirakl.com> Signed-off-by: Guy Daich <guy.daich@sap.com> Signed-off-by: Sadmi Bouhafs <sadmibouhafs@gmail.com> Signed-off-by: Matt Miller <millermatt@outlook.com> Signed-off-by: jaffar <keikei.jaffar@mail.utoronto.ca> Signed-off-by: Junnygram <junnexclusive@gmail.com> Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> Co-authored-by: zirain <zirain2009@gmail.com> Co-authored-by: Adrian Cole <64215+codefromthecrypt@users.noreply.github.com> Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com> Co-authored-by: Thierry Wandja <thierry.wandja@mirakl.com> Co-authored-by: Guy Daich <guy.daich@sap.com> Co-authored-by: Sadmi Bouhafs <sadmibouhafs@gmail.com> Co-authored-by: Matt Miller <millermatt@outlook.com> Co-authored-by: Isaac Wilson <10012479+jukie@users.noreply.github.com> Co-authored-by: jaffar keikei <keikei.jaffar@mail.utoronto.ca> Co-authored-by: Olaleye <90139191+Junnygram@users.noreply.github.com> Co-authored-by: Oliver Bähler <oliverbaehler@hotmail.com>
1 parent e3ed79d commit e55e154

149 files changed

Lines changed: 2189 additions & 1602 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build_and_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ jobs:
274274

275275
resilience-test:
276276
runs-on: ubuntu-latest
277-
if: ${{ ! (startsWith(github.event_name, 'push') && needs.changes.outputs.skip_test_workflow != 'true') }}
277+
if: ${{ github.event_name != 'pull_request' || needs.changes.outputs.run_test_workflow == 'true' }}
278278
needs:
279279
- build
280280
- changes

.github/workflows/release.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ jobs:
6060
id: vars
6161
shell: bash
6262
run: |
63-
echo "release_tag=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
64-
echo "without_v_release_tag=$(echo ${GITHUB_REF##*/v})" >> $GITHUB_ENV
65-
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
63+
{
64+
echo "release_tag=${GITHUB_REF##*/}"
65+
echo "without_v_release_tag=${GITHUB_REF##*/v}"
66+
echo "sha_short=$(git rev-parse --short HEAD)"
67+
} >> "$GITHUB_ENV"
6668
6769
- name: Login to DockerHub
6870
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.7.0-rc.1
1+
v1.7.0-rc.2

api/v1alpha1/envoygateway_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ type EnvoyGatewaySpec struct {
9191

9292
// ExtensionManager defines an extension manager to register for the Envoy Gateway Control Plane.
9393
//
94+
// Warning: Enabling an Extension Server may lead to complete security compromise of your system.
95+
// Users that control the Extension Server can inject arbitrary configuration to proxies,
96+
// leading to high Confidentiality, Integrity and Availability risks.
97+
//
9498
// +optional
9599
ExtensionManager *ExtensionManager `json:"extensionManager,omitempty"`
96100

@@ -300,6 +304,10 @@ type Gateway struct {
300304
type ExtensionAPISettings struct {
301305
// EnableEnvoyPatchPolicy enables Envoy Gateway to
302306
// reconcile and implement the EnvoyPatchPolicy resources.
307+
//
308+
// Warning: Enabling `EnvoyPatchPolicy` may lead to complete security compromise of your system.
309+
// Users with `EnvoyPatchPolicy` permissions can inject arbitrary configuration to proxies,
310+
// leading to high Confidentiality, Integrity and Availability risks.
303311
EnableEnvoyPatchPolicy bool `json:"enableEnvoyPatchPolicy"`
304312
// EnableBackend enables Envoy Gateway to
305313
// reconcile and implement the Backend resources.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ require (
4848
github.com/spf13/pflag v1.0.10
4949
github.com/stretchr/testify v1.11.1
5050
github.com/telepresenceio/watchable v0.0.0-20220726211108-9bb86f92afa7
51-
github.com/tetratelabs/func-e v1.3.0
51+
github.com/tetratelabs/func-e v1.4.0
5252
github.com/tsaarni/certyaml v0.10.0
5353
github.com/yuin/gopher-lua v1.1.1
5454
go.opentelemetry.io/otel v1.39.0
@@ -207,7 +207,7 @@ require (
207207
github.com/lib/pq v1.10.9 // indirect
208208
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
209209
github.com/longhorn/go-iscsi-helper v0.0.0-20210330030558-49a327fb024e // indirect
210-
github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect
210+
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 // indirect
211211
github.com/lyft/gostats v0.4.1 // indirect
212212
github.com/mailru/easyjson v0.9.0 // indirect
213213
github.com/mattn/go-colorable v0.1.14 // indirect

go.sum

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7O
302302
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
303303
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
304304
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
305-
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
306305
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
307306
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
308307
github.com/google/go-containerregistry v0.20.6 h1:cvWX87UxxLgaH76b4hIvya6Dzz9qHB31qAwjAohdSTU=
@@ -403,8 +402,8 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9
403402
github.com/longhorn/go-iscsi-helper v0.0.0-20210330030558-49a327fb024e h1:hz4quJkaJWDo+xW+G6wTF6d6/95QvJ+o2D0+bB/tJ1U=
404403
github.com/longhorn/go-iscsi-helper v0.0.0-20210330030558-49a327fb024e/go.mod h1:9z/y9glKmWEdV50tjlUPxFwi1goQfIrrsoZbnMyIZbY=
405404
github.com/longhorn/nsfilelock v0.0.0-20200723175406-fa7c83ad0003/go.mod h1:0CLeXlf59Lg6C0kjLSDf47ft73Dh37CwymYRKWwAn04=
406-
github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY=
407-
github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE=
405+
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 h1:PwQumkgq4/acIiZhtifTV5OUqqiP82UAl0h87xj/l9k=
406+
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
408407
github.com/lyft/gostats v0.4.1 h1:oR6p4HRCGxt0nUntmZIWmYMgyothBi3eZH2A71vRjsc=
409408
github.com/lyft/gostats v0.4.1/go.mod h1:Tpx2xRzz4t+T2Tx0xdVgIoBdR2UMVz+dKnE3X01XSd8=
410409
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
@@ -614,8 +613,8 @@ github.com/telepresenceio/telepresence/rpc/v2 v2.6.8 h1:q5V85LBT9bA/c4YPa/kMvJGy
614613
github.com/telepresenceio/telepresence/rpc/v2 v2.6.8/go.mod h1:VlgfRoXaW6Tl8IZbHmMWhITne8HY09/wOFtABHGj3ic=
615614
github.com/telepresenceio/watchable v0.0.0-20220726211108-9bb86f92afa7 h1:GMw3nEaOVyi+tNiGko5kAeRtoiEIpXNHmISyZ7fpw14=
616615
github.com/telepresenceio/watchable v0.0.0-20220726211108-9bb86f92afa7/go.mod h1:ihJ97e2gsd8GuzFF/I3B1qcik3XZLpXjumQifXi8Slg=
617-
github.com/tetratelabs/func-e v1.3.0 h1:u6FS+ec2hs9vn+vX5X2GEB9JeqCajz/A4rvlsdktnQ4=
618-
github.com/tetratelabs/func-e v1.3.0/go.mod h1:zq1g5hXTBV3rNOXruLeMquQvZse0kscUSQg9NvkUz6U=
616+
github.com/tetratelabs/func-e v1.4.0 h1:eBu8RoGQIogjCNuX1lmbO8crRopvfcu7tQO82NVL+gA=
617+
github.com/tetratelabs/func-e v1.4.0/go.mod h1:q8/N//P0lY3hTuMKwWrfq4IXIUN5pCc2J+AsE74odxo=
619618
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
620619
github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=
621620
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=

internal/cmd/server.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ func GetServerCommand(asyncErrHandler func(string, error)) *cobra.Command {
5454
RunE: func(cmd *cobra.Command, _ []string) error {
5555
runnerErrors := &message.RunnerErrors{}
5656
defer runnerErrors.Close()
57-
go message.HandleSubscription(message.Metadata{Runner: "runner-errors", Message: message.RunnerErrorsMessageName},
57+
go message.HandleSubscription(
58+
logging.NewLogger(cmd.OutOrStdout(), egv1a1.DefaultEnvoyGatewayLogging()),
59+
message.Metadata{Runner: "runner-errors", Message: message.RunnerErrorsMessageName},
5860
runnerErrors.Subscribe(cmd.Context()),
5961
func(update message.Update[string, message.WatchableError], _ chan error) {
6062
if asyncErrHandler != nil {

internal/gatewayapi/backend.go

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717

1818
egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
1919
"github.com/envoyproxy/gateway/internal/gatewayapi/status"
20-
"github.com/envoyproxy/gateway/internal/utils/net"
2120
)
2221

2322
func (t *Translator) ProcessBackends(backends []*egv1a1.Backend, backendTLSPolicies []*gwapiv1.BackendTLSPolicy) []*egv1a1.Backend {
@@ -69,17 +68,9 @@ func validateBackend(backend *egv1a1.Backend, backendTLSPolicies []*gwapiv1.Back
6968
return routeErr
7069
}
7170
} else if ep.IP != nil {
72-
ip, err := netip.ParseAddr(ep.IP.Address)
73-
if err != nil {
74-
return status.NewRouteStatusError(
75-
fmt.Errorf("IP address %s is invalid", ep.IP.Address),
76-
status.RouteReasonInvalidAddress,
77-
)
78-
} else if ip.IsLoopback() && !runningOnHost {
79-
return status.NewRouteStatusError(
80-
fmt.Errorf("IP address %s in the loopback range is only supported when using the Host infrastructure", ep.IP.Address),
81-
status.RouteReasonInvalidAddress,
82-
)
71+
routeErr := validateIP(ep.IP, runningOnHost)
72+
if routeErr != nil {
73+
return routeErr
8374
}
8475
}
8576
}
@@ -170,16 +161,17 @@ func validateBackendTLSSettings(backend *egv1a1.Backend, backendTLSPolicies []*g
170161
return nil
171162
}
172163

173-
func validateHostname(hostname, typeName string, allowLocalhost bool) *status.RouteStatusError {
164+
func validateHostname(hostname, typeName string, runningOnHost bool) *status.RouteStatusError {
174165
// must be a valid hostname
175166
if errs := validation.IsDNS1123Subdomain(hostname); errs != nil {
176167
return status.NewRouteStatusError(
177168
fmt.Errorf("hostname %s is not a valid %s", hostname, typeName),
178169
status.RouteReasonInvalidAddress,
179170
)
180171
}
181-
isLocalHostname := allowLocalhost && hostname == net.DefaultLocalAddress
182-
if !isLocalHostname && len(strings.Split(hostname, ".")) < 2 {
172+
// Host mode is a dev configuration, so we do not enforce domain rules.
173+
// Doing so would interfere with docker hostnames (e.g. "jaeger") or literal IPs.
174+
if !runningOnHost && len(strings.Split(hostname, ".")) < 2 {
183175
return status.NewRouteStatusError(
184176
fmt.Errorf("hostname %s should be a domain with at least two segments separated by dots", hostname),
185177
status.RouteReasonInvalidAddress,
@@ -195,3 +187,19 @@ func validateHostname(hostname, typeName string, allowLocalhost bool) *status.Ro
195187

196188
return nil
197189
}
190+
191+
func validateIP(epIP *egv1a1.IPEndpoint, runningOnHost bool) status.Error {
192+
ip, err := netip.ParseAddr(epIP.Address)
193+
if err != nil {
194+
return status.NewRouteStatusError(
195+
fmt.Errorf("IP address %s is invalid", epIP.Address),
196+
status.RouteReasonInvalidAddress,
197+
)
198+
} else if ip.IsLoopback() && !runningOnHost {
199+
return status.NewRouteStatusError(
200+
fmt.Errorf("IP address %s in the loopback range is only supported when using the Host infrastructure", epIP.Address),
201+
status.RouteReasonInvalidAddress,
202+
)
203+
}
204+
return nil
205+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Copyright Envoy Gateway Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
// The full text of the Apache license is available in the LICENSE file at
4+
// the root of the repo.
5+
6+
package gatewayapi
7+
8+
import (
9+
"testing"
10+
11+
"github.com/stretchr/testify/require"
12+
13+
egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
14+
)
15+
16+
func TestValidateHostnameRunningOnHost(t *testing.T) {
17+
cases := []struct {
18+
name string
19+
hostname string
20+
runningOnHost bool
21+
expectedErr string
22+
}{
23+
{
24+
name: "domain ok in any case",
25+
hostname: "httpbin.org",
26+
runningOnHost: false,
27+
},
28+
{
29+
name: "single label not ok when in k8s",
30+
hostname: "otel-tui",
31+
runningOnHost: false,
32+
expectedErr: "hostname otel-tui should be a domain with at least two segments separated by dots",
33+
},
34+
{
35+
name: "single label ok when running on host",
36+
hostname: "otel-tui",
37+
runningOnHost: true,
38+
},
39+
{
40+
name: "IP not ok in any case",
41+
hostname: "127.0.0.1",
42+
runningOnHost: true,
43+
expectedErr: "hostname 127.0.0.1 is an IP address",
44+
},
45+
}
46+
47+
for _, tc := range cases {
48+
t.Run(tc.name, func(t *testing.T) {
49+
err := validateHostname(tc.hostname, "hostname", tc.runningOnHost)
50+
if tc.expectedErr == "" {
51+
require.Nil(t, err)
52+
return
53+
}
54+
require.EqualError(t, err, tc.expectedErr)
55+
})
56+
}
57+
}
58+
59+
func TestValidateIPRunningOnHost(t *testing.T) {
60+
cases := []struct {
61+
name string
62+
address string
63+
runningOnHost bool
64+
expectedErr string
65+
}{
66+
{
67+
name: "address ok in any case",
68+
address: "10.0.0.1",
69+
runningOnHost: false,
70+
},
71+
{
72+
name: "loopback not ok when in k8s",
73+
address: "127.0.0.1",
74+
runningOnHost: false,
75+
expectedErr: "IP address 127.0.0.1 in the loopback range is only supported when using the Host infrastructure",
76+
},
77+
{
78+
name: "loopback ok when running on host",
79+
address: "127.0.0.1",
80+
runningOnHost: true,
81+
},
82+
{
83+
name: "invalid IP not ok in any case",
84+
address: "300.0.0.1",
85+
runningOnHost: true,
86+
expectedErr: "IP address 300.0.0.1 is invalid",
87+
},
88+
}
89+
90+
for _, tc := range cases {
91+
t.Run(tc.name, func(t *testing.T) {
92+
err := validateIP(&egv1a1.IPEndpoint{Address: tc.address}, tc.runningOnHost)
93+
if tc.expectedErr == "" {
94+
require.Nil(t, err)
95+
return
96+
}
97+
require.EqualError(t, err, tc.expectedErr)
98+
})
99+
}
100+
}

internal/gatewayapi/backendtrafficpolicy.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,10 +952,41 @@ func (t *Translator) buildTrafficFeatures(policy *egv1a1.BackendTrafficPolicy) (
952952
RequestBuffer: rb,
953953
Compression: cp,
954954
HTTPUpgrade: httpUpgrade,
955-
Telemetry: policy.Spec.Telemetry,
955+
Telemetry: buildBackendTelemetry(policy.Spec.Telemetry),
956956
}, errs
957957
}
958958

959+
func buildBackendTelemetry(telemetry *egv1a1.BackendTelemetry) *ir.BackendTelemetry {
960+
if telemetry == nil {
961+
return nil
962+
}
963+
return &ir.BackendTelemetry{
964+
Tracing: buildBackendTracing(telemetry.Tracing),
965+
Metrics: buildBackendMetrics(telemetry.Metrics),
966+
}
967+
}
968+
969+
func buildBackendTracing(tracing *egv1a1.Tracing) *ir.BackendTracing {
970+
if tracing == nil {
971+
return nil
972+
}
973+
return &ir.BackendTracing{
974+
SamplingFraction: tracing.SamplingFraction,
975+
CustomTags: ir.CustomTagMapToSlice(tracing.CustomTags),
976+
Tags: ir.MapToSlice(tracing.Tags),
977+
SpanName: tracing.SpanName,
978+
}
979+
}
980+
981+
func buildBackendMetrics(metrics *egv1a1.BackendMetrics) *ir.BackendMetrics {
982+
if metrics == nil {
983+
return nil
984+
}
985+
return &ir.BackendMetrics{
986+
RouteStatName: metrics.RouteStatName,
987+
}
988+
}
989+
959990
func (t *Translator) translateBackendTrafficPolicyForGateway(
960991
policy *egv1a1.BackendTrafficPolicy, target gwapiv1.LocalPolicyTargetReferenceWithSectionName,
961992
gateway *GatewayContext, xdsIR resource.XdsIRMap,

0 commit comments

Comments
 (0)