Kong / kubernetes-ingress-controller

:gorilla: Kong for Kubernetes: The official Ingress Controller for Kubernetes.
https://docs.konghq.com/kubernetes-ingress-controller/
Apache License 2.0
2.21k stars 591 forks source link

The `RequestRedirect` filter on a Kubernetes Gateway API `HTTPRoute` leads to logs spamming in the KIC controller #6535

Open konsti opened 3 weeks ago

konsti commented 3 weeks ago

Is there an existing issue for this?

Current Behavior

When I create an HTTPRoute that uses the RequestRedirect filter, my controller instance spams logs like:

2024-09-30T15:10:24Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:10:27Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:10:30Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:10:33Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:10:36Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:10:39Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:10:42Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:10:45Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:10:48Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:10:51Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:10:54Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:10:57Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:11:00Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:11:03Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:11:06Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:11:09Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:11:12Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}
2024-09-30T15:11:15Z  info  No targets found to create upstream {"v": 0, "service_name": "httproute.namespace.route-name.0"}

The actual redirect works.

Expected Behavior

No info log spam regarding the upstream targets is being created.

Steps To Reproduce

  1. Deploy the KIC
  2. Create a HTTPRoute:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: route-name
  namespace: namespace
spec:
  hostnames:
    - app.domain.example
  parentRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: kong
      namespace: kong-system
  rules:
    - filters:
        - requestRedirect:
            hostname: app.domain.example
            path:
              replaceFullPath: /chat
              type: ReplaceFullPath
            port: 443
            scheme: https
            statusCode: 302
          type: RequestRedirect
      matches:
        - path:
            type: PathPrefix
            value: /

Kong Ingress Controller version

3.3.0

Kubernetes version

Server Version: v1.30.4+k3s1

Anything else?

No response

konsti commented 2 weeks ago

Also here: https://github.com/Kong/kong/issues/13724

randmonkey commented 1 week ago

@konsti KIC would log a warning message if an HTTPRoute have no backend in a rule or the backend service has no available targets, since the translated Kong service does not have a target is likely to be unavailable. Since we are now having the redirect filter which does not need a target for the service, I think we can remove it in the condition where the redirect filter is added (or some kind of redirect plugin attached).