envoyproxy / envoy-wasm

*ATTENTION!: The content of this repo is merged into https://github.com/envoyproxy/envoy and future development is happening there.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to get a WASM network filter invoked

mbanikazemi opened this issue · comments

commented

I use the only sample WASM network filter I could find that has some log statement as for example shown below:

FilterStatus ExampleContext::onDownstreamData(size_t data_length, bool end_stream) {
  WasmDataPtr data = getBufferBytes(BufferType::NetworkDownstreamData, 0, data_length);
  logInfo("onDownstreamData " + std::to_string(id()) + " len=" + std::to_string(data_length) +
           " end_stream=" + std::to_string(end_stream) + "\n" + std::string(data->view()));
  return FilterStatus::Continue;
}

I build the WASM filter.

I create an Istio EnvoyFilter by applying the following:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: tcpbanixnetwork1
  namespace: default
spec:
  configPatches:
  - applyTo: NETWORK_FILTER
    match:
      listener:
        portNumber: 80
      context: SIDECAR_INBOUND
      proxy:
        proxyVersion: 1\.5.*
    patch:
      operation: INSERT_FIRST
      value:
        name: "envoy.filters.network.wasm"
        typed_config:
          '@type': type.googleapis.com/udpa.type.v1.TypedStruct
          type_url: type.googleapis.com/envoy.config.filter.network.wasm.v2.Wasm
          value:
            config:
              vmConfig:
                code:
                  local:
                    filename: /var/local/lib/wasme-cache/3bc4d8ea70e79f8998c7679dbfedd7c597be6c8e2c810136e8d1265b4cc0f7e1
                runtime: envoy.wasm.runtime.v8
                vmId: add_tcp_root_id
  workloadSelector:
    labels:
      app: httpbin

I see the filter being added by Istio when I look at the Envoy config dump:

....
       "filter_chains": [
        {
         "filters": [
          {
           "name": "envoy.filters.network.wasm",
           "typed_config": {
            "@type": "type.googleapis.com/udpa.type.v1.TypedStruct",
            "type_url": "type.googleapis.com/envoy.config.filter.network.wasm.v2.Wasm",
            "value": {
             "config": {
              "vm_config": {
               "vm_id": "add_tcp_root_id",
               "runtime": "envoy.wasm.runtime.v8",
               "code": {
                "local": {
                 "filename": "/var/local/lib/wasme-cache/3bc4d8ea70e79f8998c7679dbfedd7c597be6c8e2c810136e8d1265b4cc0f7e1"
                }
               }
              }
             }
            }
           }
          },
          {
           "name": "envoy.filters.network.metadata_exchange",
           "config": {
            "protocol": "istio-peer-exchange"
           }
          },
...

I never seem to get my code invoked. I have a http WASM filter on the same filter chain and that gets invoked and I see the logs from it. I do not get any of the log statements I expect to see from the network filter.

What am I missing?

commented

@jplevyak @PiotrSikora Is the proxy version 1.5.* ok? Could that be an issue?

Are you running Istio Proxy / Envoy with tuned log levels? By default, info isn't logged.

commented

@PiotrSikora yes, I turn it on. I can see the info logs from my http filter but not from the network filter shown above.

commented

to be more specific on the WASM http filter I have a log statement in onRequestHeaders() and I see the output of that.

commented

Changed approach for building and testing WASM network filters.