EnvoyFilterUsesRelativeOperation
當 EnvoyFilter
沒有優先順序且使用相對修補操作 (INVALID
、MERGE
、REMOVE
、INSERT_BEFORE
、INSERT_AFTER
、REPLACE
) 時,會發生此訊息。使用相對修補操作表示該操作取決於在評估目前 EnvoyFilter
過濾器時是否存在另一個過濾器。為了確保 EnvoyFilters
以使用者想要的順序套用,應該給予優先順序或應使用非相對操作 (ADD
或 INSERT_FIRST
)。
範例
考慮具有修補操作 INSERT_BEFORE
的 EnvoyFilter
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: test-relative
namespace: bookinfo
spec:
workloadSelector:
labels:
app: reviews2
configPatches:
# The first patch adds the Lua filter to the listener/http connection manager
- applyTo: HTTP_FILTER
match:
context: SIDECAR_INBOUND
listener:
portNumber: 8080
filterChain:
filter:
name: "envoy.filters.network.http_connection_manager"
subFilter:
name: "envoy.filters.http.router"
patch:
operation: INSERT_BEFORE
value: # Lua filter specification
name: envoy.lua
typed_config:
"@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua"
inlineCode: |
function envoy_on_request(request_handle)
-- Make an HTTP call to an upstream host with the following headers, body, and timeout.
local headers, body = request_handle:httpCall(
"lua_cluster",
{
[":method"] = "POST",
[":path"] = "/acl",
[":authority"] = "internal.org.net"
},
"authorize call",
5000)
end
如何解決
由於使用了 INSERT_BEFORE
的相對操作,將其變更為 INSERT_FIRST
的絕對操作將解決此問題
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: test-relative
namespace: bookinfo
spec:
workloadSelector:
labels:
app: reviews2
configPatches:
# The first patch adds the Lua filter to the listener/http connection manager
- applyTo: HTTP_FILTER
match:
context: SIDECAR_INBOUND
listener:
portNumber: 8080
filterChain:
filter:
name: "envoy.filters.network.http_connection_manager"
subFilter:
name: "envoy.filters.http.router"
patch:
operation: INSERT_FIRST
value: # Lua filter specification
name: envoy.lua
typed_config:
"@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua"
inlineCode: |
function envoy_on_request(request_handle)
-- Make an HTTP call to an upstream host with the following headers, body, and timeout.
local headers, body = request_handle:httpCall(
"lua_cluster",
{
[":method"] = "POST",
[":path"] = "/acl",
[":authority"] = "internal.org.net"
},
"authorize call",
5000)
end