EnvoyFilterUsesReplaceOperationIncorrectly

消息名称EnvoyFilterUsesReplaceOperationIncorrectly
消息代码IST0152
描述The REPLACE operation is only valid for HTTP_FILTER and NETWORK_FILTER.
等级Error

EnvoyFilter 使用 REPLACE 操作并且 ApplyTo 设置为 HTTP_FILTERNETWORK_FILTER 时, 会出现此消息。这将导致 REPLACE 操作被忽略,因为 HTTP_FILTERNETWORK_FILTER 对于 REPLACE 无效。

示例

以一个带有 REPLACE 补丁操作的 EnvoyFilter 为例,这个 EnvoyFilter 将被忽略:

  1. apiVersion: networking.istio.io/v1alpha3
  2. kind: EnvoyFilter
  3. metadata:
  4. name: test-replace-2
  5. namespace: bookinfo
  6. spec:
  7. workloadSelector:
  8. labels:
  9. app: reviews2
  10. priority: 10
  11. configPatches:
  12. # 第一个补丁将 Lua 过滤器添加到 listener/http 连接管理器
  13. - applyTo: HTTP_FILTER
  14. match:
  15. context: SIDECAR_INBOUND
  16. listener:
  17. portNumber: 8080
  18. filterChain:
  19. filter:
  20. name: "envoy.filters.network.http_connection_manager"
  21. subFilter:
  22. name: "envoy.filters.http.router"
  23. patch:
  24. operation: REPLACE
  25. value: # Lua filter specification
  26. name: envoy.lua
  27. typed_config:
  28. "@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua"
  29. inlineCode: |
  30. function envoy_on_request(request_handle)
  31. -- Make an HTTP call to an upstream host with the following headers, body, and timeout.
  32. local headers, body = request_handle:httpCall(
  33. "lua_cluster",
  34. {
  35. [":method"] = "POST",
  36. [":path"] = "/acl",
  37. [":authority"] = "internal.org.net"
  38. },
  39. "authorize call",
  40. 5000)
  41. end