Skip to content

bug: panic nil pointer #2966

@zetaab

Description

@zetaab

Description:

Added following configuration and envoy-gateway is in crashloop and panicing:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: mattermost-test
  namespace: mattermost-test
spec:
  parentRefs:
  - name: internal
    namespace: envoy-gateway-system
    sectionName: https
  hostnames:
  - mattermost.foobar.com
  rules:
  - backendRefs:
    - group: ""
      kind: Service
      name: mattermost-test
      port: 8080
      weight: 1
    matches:
    - path:
        type: PathPrefix
        value: /
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: BackendTLSPolicy
metadata:
  name: mattermost-test
  namespace: mattermost-test
spec:
  targetRef:
    group: ''
    kind: Service
    name: mattermost-test
  tls:
    wellKnownCACerts: System
    hostname: mattermost.foobar.com

If I add sectionName to targetRef it starts to work. However, sectionName is marked as optional in official api spec. https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io%2fv1alpha2.PolicyTargetReference https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io%2fv1alpha2.PolicyTargetReferenceWithSectionName

Environment:
eg 1.0.0

Logs:

2024-03-18T07:13:08.064Z        INFO    provider        status/status.go:122    received a status update        {"runner": "provider", "namespace": "mattermost-test", "name": "mattermost-test"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x1eab74d]

goroutine 121 [running]:
github.com/envoyproxy/gateway/internal/xds/translator.findXdsSecret(...)
        /home/runner/work/gateway/gateway/internal/xds/translator/translator.go:546
github.com/envoyproxy/gateway/internal/xds/translator.addXdsSecret(0xc000d9b540, 0xc002d03630)
        /home/runner/work/gateway/gateway/internal/xds/translator/translator.go:556 +0x12d
github.com/envoyproxy/gateway/internal/xds/translator.createOAuth2Secrets(0xc000d9b540?, {0xc002a8ad60, 0x4, 0x0?})
        /home/runner/work/gateway/gateway/internal/xds/translator/oidc.go:277 +0x8f
github.com/envoyproxy/gateway/internal/xds/translator.(*oidc).patchResources(0x0, 0xc000d9b540?, {0xc002a8ad60, 0x4, 0x4})
        /home/runner/work/gateway/gateway/internal/xds/translator/oidc.go:190 +0x51
github.com/envoyproxy/gateway/internal/xds/translator.patchResources(...)
        /home/runner/work/gateway/gateway/internal/xds/translator/httpfilters.go:214
github.com/envoyproxy/gateway/internal/xds/translator.(*Translator).processHTTPListenerXdsTranslation(0xc002613110, 0xc000d9b540, {0xc002b6a2d0, 0x3, 0x2583ede?}, 0x25818a1?, 0x1?, 0x0)
        /home/runner/work/gateway/gateway/internal/xds/translator/translator.go:301 +0x12b2
github.com/envoyproxy/gateway/internal/xds/translator.(*Translator).Translate(0xc002613110, 0xc002a94a00)
        /home/runner/work/gateway/gateway/internal/xds/translator/translator.go:81 +0x7f
github.com/envoyproxy/gateway/internal/xds/translator/runner.(*Runner).subscribeAndTranslate.func1({{0xc0008717a0?, 0x0?}, 0x40?, 0xc002a94a00?}, 0xa?)
        /home/runner/work/gateway/gateway/internal/xds/translator/runner/runner.go:81 +0x24d
github.com/envoyproxy/gateway/internal/message.HandleSubscription[...]({{0x257bef6, 0x28e9be8?}, {0x256efa7?, 0x0?}}, 0xc00007e7e0?, 0xc002613f98)
        /home/runner/work/gateway/gateway/internal/message/watchutil.go:76 +0x112d
github.com/envoyproxy/gateway/internal/xds/translator/runner.(*Runner).subscribeAndTranslate(0xc0002c2680, {0x28e9be8?, 0xc000820280?})
        /home/runner/work/gateway/gateway/internal/xds/translator/runner/runner.go:53 +0x85
created by github.com/envoyproxy/gateway/internal/xds/translator/runner.(*Runner).Start in goroutine 1
        /home/runner/work/gateway/gateway/internal/xds/translator/runner/runner.go:46 +0x26e

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions