Skip to content

Panic when using SectionName in BackendTrafficPolicy #7752

@Jean-Daniel

Description

@Jean-Daniel

Description:

Using Envoy Gateway 1.6.1, when trying to use a BackendTrafficPolicy targeting a specific route rule using sectionName, the controller panic with the following error:

runtime error: invalid memory address or nil pointer dereference

github.com/envoyproxy/gateway/internal/gatewayapi.(*Translator).applyTrafficFeatureToRoute(0xc001f0d8b8, {0x8e00580?, 0xc0049130e0?}, 0xc001708d10, {0x0, 0x0}, 0xc0022e7b08, {{{0xc004496e80, 0x19}, {0xc0045c9560, ...}, ...}, ...}, ...)
	/home/runner/work/gateway/gateway/internal/gatewayapi/backendtrafficpolicy.go:769 +0x768
github.com/envoyproxy/gateway/internal/gatewayapi.(*Translator).translateBackendTrafficPolicyForRoute(0xc001f0d8b8, 0xc0022e7b08, {0x8e00580, 0xc0049130e0}, {{{0xc004496e80, 0x19}, {0xc0045c9560, 0x9}, {0xc0045c9569, 0x7}}, ...}, ...)
	/home/runner/work/gateway/gateway/internal/gatewayapi/backendtrafficpolicy.go:639 +0x2ca
github.com/envoyproxy/gateway/internal/gatewayapi.(*Translator).processBackendTrafficPolicyForRoute(0xc001f0d8b8, 0xc00291d908, 0xc004b73950, 0xc001f0c920, 0xc001f0c260, 0xc001f0cb90, 0xc001f0c230, 0xc0022e7b08, {{{0xc004496e80, 0x19}, ...}, ...})
	/home/runner/work/gateway/gateway/internal/gatewayapi/backendtrafficpolicy.go:333 +0x14dc
github.com/envoyproxy/gateway/internal/gatewayapi.(*Translator).ProcessBackendTrafficPolicies(0xc001f0d8b8, 0xc00291d908, {0xc00241e820, 0x4, 0x4}, {0xc001051a40, 0x13, 0x13}, 0xc004b73950)
	/home/runner/work/gateway/gateway/internal/gatewayapi/backendtrafficpolicy.go:107 +0x197c
github.com/envoyproxy/gateway/internal/gatewayapi.(*Translator).Translate(0xc001f0d8b8, 0xc00291d908)
	/home/runner/work/gateway/gateway/internal/gatewayapi/translator.go:284 +0x848
github.com/envoyproxy/gateway/internal/gatewayapi/runner.(*Runner).subscribeAndTranslate.func1({{0xc0001bcea0?, 0xc003530d50?}, 0xd0?, 0xc001b89cf8?}, 0xc000801500)
	/home/runner/work/gateway/gateway/internal/gatewayapi/runner/runner.go:176 +0x571
github.com/envoyproxy/gateway/internal/message.handleWithCrashRecovery[...](0xc001f0dfa0?, {{0xc0001bcea0, 0x0?}, 0x18?, 0xc001b89cf8?}, {{0x3cc01c7, 0xb}, {0x3cd404b, 0x12}}, 0xc000801500?)
	/home/runner/work/gateway/gateway/internal/message/watchutil.go:64 +0x137
github.com/envoyproxy/gateway/internal/message.HandleSubscription[...]({{0x3cc01c7, 0xc001213c01?}, {0x3cd404b?, 0x1afa8?}}, 0xc00019d960?, 0xc001f0dfa0)
	/home/runner/work/gateway/gateway/internal/message/watchutil.go:104 +0x7fd
github.com/envoyproxy/gateway/internal/gatewayapi/runner.(*Runner).subscribeAndTranslate(0xc000bb32b0, 0xc0015f0b30?)
	/home/runner/work/gateway/gateway/internal/gatewayapi/runner/runner.go:126 +0x50
created by github.com/envoyproxy/gateway/internal/gatewayapi/runner.(*Runner).Start in goroutine 183
	/home/runner/work/gateway/gateway/internal/gatewayapi/runner/runner.go:89 +0x31e

Repro steps:

First install a envoy gateway with 2 routes:

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/name: gateway
  name: gateway
  namespace: default
spec:
  provider:
    kubernetes:
      envoyDeployment:
        replicas: 1
      envoyService:
        allocateLoadBalancerNodePorts: false
        labels:
          load-balancer.xooloo.com/pool: auto
        loadBalancerClass: io.cilium/bgp-control-plane
    type: Kubernetes
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  labels:
    app.kubernetes.io/instance: gateway
    app.kubernetes.io/name: gateway
  name: gateway
  namespace: default
spec:
  gatewayClassName: envoy-default
  infrastructure:
    parametersRef:
      group: gateway.envoyproxy.io
      kind: EnvoyProxy
      name: gateway
  listeners:
  - allowedRoutes:
      namespaces:
        from: Same
    hostname: example.com
    name: example.com-http
    port: 80
    protocol: HTTP
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  labels:
    app.kubernetes.io/instance: https-redirect
    app.kubernetes.io/name: https-redirect
    app.kubernetes.io/part-of: crash
  name: https-redirect
  namespace: default
spec:
  hostnames:
  - example.com
  parentRefs:
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: gateway
  rules:
  - backendRefs:
    - name: https
      port: 8080
    matches:
    - path:
        type: PathPrefix
        value: /
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: ws-test
  namespace: default
spec:
  hostnames:
    - "example.com"
  parentRefs:
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: gateway
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /
    name: default

Then deploy the BackendTrafficPolicy:

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
  name: ws-test
  namespace: default
spec:
  mergeType: StrategicMerge
  targetRefs:
  - group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: ws-test
    sectionName: default

Environment:

Envoy Gateway 1.6.1 / Kubernetes 1.33.6

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions