gateway icon indicating copy to clipboard operation
gateway copied to clipboard

Route with multiple parents has incorrect namespace in parentref status

Open adam-cattermole opened this issue 1 year ago • 1 comments

Description: Creating a route with multiple parents with inferred namespaces shows incorrect namespace in parentRef status

Repro steps:

  • Create namespace:
kubectl create namespace test
  • Create two gateways and a route targeting them:
kubectl apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: gateway-a
  namespace: test
spec:
  gatewayClassName: envoygateway
  listeners:
  - name: default
    port: 80
    protocol: HTTP
    hostname: '*.a.example.com'
    allowedRoutes:
      namespaces:
        from: All
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: gateway-b
  namespace: test
spec:
  gatewayClassName: envoygateway
  listeners:
    - name: default
      port: 80
      protocol: HTTP
      hostname: '*.b.example.com'
      allowedRoutes:
        namespaces:
          from: All
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: targeted-route
  namespace: test
spec:
  hostnames:
    - targeted.a.example.com
    - targeted.b.example.com
  parentRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: gateway-a
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: gateway-b
  rules:
    - matches:
        - method: GET
          path:
            type: PathPrefix
            value: /toy
EOF
  • Get the route from the cluster kubectl get -n test httproute targeted-route -o yaml:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"gateway.networking.k8s.io/v1","kind":"HTTPRoute","metadata":{"annotations":{},"name":"targeted-route","namespace":"test"},"spec":{"hostnames":["targeted.a.example.com","targeted.b.example.com"],"parentRefs":[{"group":"gateway.networking.k8s.io","kind":"Gateway","name":"gateway-a"},{"group":"gateway.networking.k8s.io","kind":"Gateway","name":"gateway-b"}],"rules":[{"matches":[{"method":"GET","path":{"type":"PathPrefix","value":"/toy"}}]}]}}
  creationTimestamp: "2024-08-30T15:30:52Z"
  generation: 1
  name: targeted-route
  namespace: test
  resourceVersion: "24649"
  uid: 0498bdf7-7095-4236-8b17-c4933cf69b54
spec:
  hostnames:
  - targeted.a.example.com
  - targeted.b.example.com
  parentRefs:
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: gateway-a
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: gateway-b
  rules:
  - matches:
    - method: GET
      path:
        type: PathPrefix
        value: /toy
status:
  parents:
  - conditions:
    - lastTransitionTime: "2024-08-30T15:30:52Z"
      message: Route is accepted
      observedGeneration: 1
      reason: Accepted
      status: "True"
      type: Accepted
    - lastTransitionTime: "2024-08-30T15:30:52Z"
      message: Resolved all the Object references for the Route
      observedGeneration: 1
      reason: ResolvedRefs
      status: "True"
      type: ResolvedRefs
    controllerName: gateway.envoyproxy.io/gatewayclass-controller
    parentRef:
      group: gateway.networking.k8s.io
      kind: Gateway
      name: gateway-a
  - conditions:
    - lastTransitionTime: "2024-08-30T15:30:52Z"
      message: Route is accepted
      observedGeneration: 1
      reason: Accepted
      status: "True"
      type: Accepted
    - lastTransitionTime: "2024-08-30T15:30:52Z"
      message: Resolved all the Object references for the Route
      observedGeneration: 1
      reason: ResolvedRefs
      status: "True"
      type: ResolvedRefs
    controllerName: gateway.envoyproxy.io/gatewayclass-controller
    parentRef:
      group: gateway.networking.k8s.io
      kind: Gateway
      name: gateway-b
      namespace: default

Note that the status.parents.[].parentRef for gateway-b incorrectly states the namespace as default.

Environment: envoy-gateway v1.1, kind, gateway-api v1.1

adam-cattermole avatar Aug 30 '24 15:08 adam-cattermole

I cannot reproduce it with envoygateway v1.0.0

eguzki avatar Aug 30 '24 16:08 eguzki