Skip to content

Direct Response Route incorrectly being configured #4704

@alexandermarston

Description

@alexandermarston

Description:

Since upgrading to v1.2.1, we have noticed one of our HTTPRoutes behaving in an odd way. It appears that some HTTPRoutes are being translated into EG routes with a direct response of 500.

Rolling back to v1.1.0 fixes this.

Repro steps:

We have a HTTPRoute that looks something like:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: account-mapping
  namespace: dev
spec:
  hostnames:
  - account.dev.web.io
  parentRefs:
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: dev
    namespace: envoy-gateway
  rules:
  - backendRefs:
    - group: ""
      kind: Service
      name: account
      port: 80
      weight: 1
    matches:
    - path:
        type: PathPrefix
        value: /

I would expect this to produce a route that looks something like this:

{
    "match": {
        "prefix": "/"
    },
    "metadata": {
        "filterMetadata": {
            "envoy-gateway": {
                "resources": [
                    {
                        "kind": "HTTPRoute",
                        "name": "account-mapping",
                        "namespace": "dev"
                    }
                ]
            }
        }
    },
    "name": "httproute/dev/account-mapping/rule/0/match/0/account_dev_web_io",
    "route": {
        "cluster": "httproute/dev/account-mapping/rule/0",
        "upgradeConfigs": [
            {
                "upgradeType": "websocket"
            }
        ]
    }
}

However, we are ending up with a translated route that looks like this:

{
    "directResponse": {
        "status": 500
    },
    "match": {
        "prefix": "/"
    },
    "metadata": {
        "filterMetadata": {
            "envoy-gateway": {
                "resources": [
                    {
                        "kind": "HTTPRoute",
                        "name": "account-mapping",
                        "namespace": "dev"
                    }
                ]
            }
        }
    },
    "name": "httproute/dev/account-mapping/rule/0/match/0/account_dev_web_io"
}

We do have a seperate HTTPRoute for the same domain, with some separate rules - these endpoints are working fine.

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: account-mapping-unauthenticated-0
  namespace: dev
spec:
  hostnames:
  - account.dev.web.io
  parentRefs:
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: dev
    namespace: envoy-gateway
  rules:
  - backendRefs:
    - group: ""
      kind: Service
      name: account
      port: 80
      weight: 1
    matches:
    - path:
        type: Exact
        value: /countries
  - backendRefs:
    - group: ""
      kind: Service
      name: account
      port: 80
      weight: 1
    matches:
    - path:
        type: RegularExpression
        value: /webhooks/[^/]+$

Note: If there are privacy concerns, sanitize the data prior to
sharing.

Environment:

Envoy Gateway v1.2.1

Logs:

{
    "bytes_received": 0,
    "x-forwarded-for": "xxxxx",
    "protocol": "HTTP/1.1",
    "response_code": 500,
    "route_name": "httproute/dev/account-mapping/rule/0/match/0/account_dev_web_io",
    "downstream_remote_address": "xxxx",
    "response_flags": "-",
    "start_time": "2024-11-11T15:36:09.995Z",
    "authority": "account.dev.web.io",
    "x-request-id": "8503f06f-60a6-4fe7-90ac-36c970aaa6c1",
    "bytes_sent": 0,
    "response_code_details": "direct_response",
    "downstream_local_address": "xxxxx",
    "method": "GET",
    "x-envoy-origin-path": "/",
    "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
    "duration": 0
}

Metadata

Metadata

Assignees

No one assigned

    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