kubernetesistioistio-sidecar

k8s, Istio: remove transfer-encoding header



In application's responses we see doubled transfer-encoding headers.
Suppose, because of that we get 503 in UI, but at the same time application returns 201 in pod's logs.
Except http code: 201 there are transfer-encoding=chunked and Transfer-Encoding=chunked headers in logs, so that could be a reason of 503.
We've tried to remove transfer-encoding via Istio virtual service or envoy filter, but no luck..

Here are samples we tried:

VS definition:

kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
metadata:
  name: test
  namespace: my-ns
spec:
  hosts:
    - my-service
  http:
    - route:
        - destination:
            host: my-service
          headers:
            response:
              remove:
                - transfer-encoding

---
kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
metadata:
  name: test
  namespace: istio-system
spec:
  gateways:
    - wildcard-api-gateway
  hosts:
    - my-ns_domain
  http:
    - match:
        - uri:
            prefix: /operator/api/my-service
      rewrite:
        uri: /my-service
      route:
        - destination:
            host: >-
              my-service.my-ns.svc.cluster.local
            port:
              number: 8080
          headers:
            response:
              remove:
                - transfer-encoding

EnvoyFilter definition:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: test
  namespace: istio-system
spec:
  configPatches:
  - applyTo: HTTP_FILTER
    match:
      context: SIDECAR_OUTBOUND
    patch:
      operation: ADD
      value:
        name: envoy.filters.http.lua
        typed_config:
          "@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua"
          inlineCode: |
           function envoy_on_response(response_handle)
             response_handle:headers():remove("transfer-encoding")
           end

In older envoy versions I see envoy.reloadable_features.reject_unsupported_transfer_encodings=false was a workaround. Unfortunately, it was deprecated.

Please advise what is wrong with VS/filter or is there any alternative to reject_unsupported_transfer_encodings option?

Istio v1.8.2
Envoy v1.16.1


Solution

  • Decision so far: created requirement for dev team to remove the duplication of chunked encoding