Envoy: http call cluster invalid. Must be configured

Hey guys,

I’ve set up istio version 1.7.3 and I’ve added an envoy filter (see below). I see this error sometimes in the istio-proxy logs.

http call cluster invalid. Must be configured

Is there any way I can debug it to see what’s happening? It only happens sometimes.

Envoy filter

kind: EnvoyFilter
apiVersion: networking.istio.io/v1alpha3
metadata: <omitted>
spec:
  configPatches:
    - applyTo: HTTP_FILTER
      match:
        context: ANY
        listener:
          filterChain:
            filter:
              name: envoy.http_connection_manager
        proxy:
          proxyVersion: ^1\.7.*
      patch:
        operation: INSERT_BEFORE
        value:
          name: envoy.filters.http.lua
          typed_config:
            '@type': type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
            inlineCode: |
              function get_value(keyvaluepairs, key)
                for value in string.gmatch(keyvaluepairs, key .. "=([^;]*)") do
                  return value
                end
              end

              -- Called on the request path.
              function envoy_on_request(request_handle)
                local id_token = nil
                local cookies = request_handle:headers():get("cookie")
                if cookies ~= nil then
                  id_token = get_value(cookies, "auth%-token")
                end

                local headers =  {
                  [":method"] = "POST",
                  [":path"] = "/apis/v1beta1/auth",
                  [":authority"] = "core.vafilor.svc.local",
                  ["grpc-metadata-x-original-method"] = request_handle:headers():get(":method"),
                  ["grpc-metadata-x-original-authority"] = request_handle:headers():get(":authority"),
                  ["grpc-metadata-x-original-uri"] = request_handle:headers():get(":path")
                }

                if id_token ~= nil then
                  headers["authorization"] = "Bearer " .. id_token
                end

                local response_headers, response_body = request_handle:httpCall(
                    "outbound_.80_._.core.vafilor.svc.cluster.local",
                    headers,
                    "",
                    5000
                )

                if tonumber(response_headers[":status"]) ~= 200 then
                  print("Not authorized.")
                  request_handle:respond(
                    {[":status"] = response_headers[":status"]},
                    response_body
                  )
                end
              end

This is an envoy error saying that the cluster you are trying to call is not in the clusters list. you should be able to see the clusters in istioctl pc clusters

Facing similar issue any idea around it. My filter:-

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: auth-test-filter
  namespace: istio-system
spec:
  workloadSelector:
    labels:
      istio: ingressgateway
  configPatches:
  - applyTo: HTTP_FILTER
    match:
      context: GATEWAY
      listener:
        filterChain:
          filter:
            name: "envoy.filters.network.http_connection_manager"
            subFilter:
              name: "envoy.filters.http.router"
    patch:
      operation: INSERT_BEFORE
      value:
        name: envoy.lua
        typed_config:
          "@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua"
          inlineCode: |
            function envoy_on_request(request_handle)
               local cluster_name = "outbound.9080..productpage.bookinfo.svc.cluster.local";
               local cluster_name_1 = "outbound|9080||productpage.bookinfo.svc.cluster.local";

               request_handle:logInfo("Random log");
               request_handle:logInfo("Response "..cluster_name);
               request_handle:logInfo("Response "..cluster_name_1);


               local headers, body = request_handle:httpCall(
                "productpage.bookinfo.svc.cluster.local",
                {
                  [":method"] = "GET",
                  [":path"] = "/productpage",
                  [":authority"] = "productpage.bookinfo.svc.cluster.local"
                },
                "",
                5000);
                request_handle:logInfo("Response "..headers);
            end