Skip to content

Deployment to istio ingress-gateway does not seem to work #267

Open
@munjalpatel

Description

Describe the bug
I am trying to deploy a filter directly into istio ingress-gateway but it does not seem to be working.
I don't get any errors, but I also don't get updated response headers as requested in the filter.

To Reproduce

  1. Create a new tinygo filter
# select tinygo and istio options
wasme init ./test-filter
  1. Build and publish the filter
wasme build tinygo ./test-filter-t webassemblyhub.io/company/test-filter:0.1.0
wasme push webassemblyhub.io/company/test-filter:0.1.0
  1. Deploy the filter to istio ingress gateway
wasme deploy istio webassemblyhub.io/company/test-filter:0.1.0 --id test-filter --namespace istio-system --labels istio=ingressgateway
  1. Make an HTTP request that goes through Istio ingress gateway.

Expected behavior
In the response, I would expect a header with key hello and value world
However, notice that the header in the response is not present.

Additional context
Istio version:

client version: 1.9.1
control plane version: 1.9.1
data plane version: 1.9.1 (45 proxies)

Here is the code for the filter:

main.go

package main

import (
	"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm"
	"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types"
)

// Other examples can be found at https://github.com/tetratelabs/proxy-wasm-go-sdk/tree/v0.1.1/examples

func main() {
	proxywasm.SetNewRootContext(newRootContext)
}

type httpHeaders struct {
	// we must embed the default context so that you need not to reimplement all the methods by yourself
	proxywasm.DefaultHttpContext
	contextID uint32
}

type rootContext struct {
	// You'd better embed the default root context
	// so that you don't need to reimplement all the methods by yourself.
	proxywasm.DefaultRootContext
}

func newRootContext(uint32) proxywasm.RootContext { return &rootContext{} }

// Override DefaultRootContext.
func (*rootContext) NewHttpContext(contextID uint32) proxywasm.HttpContext {
	return &httpHeaders{contextID: contextID}
}

// Override DefaultHttpContext.
func (ctx *httpHeaders) OnHttpRequestHeaders(numHeaders int, endOfStream bool) types.Action {
	hs, err := proxywasm.GetHttpRequestHeaders()
	if err != nil {
		proxywasm.LogCriticalf("failed to get request headers: %v", err)
	}

	for _, h := range hs {
		proxywasm.LogInfof("request header: %s: %s", h[0], h[1])
	}
	return types.ActionContinue
}

// Override DefaultHttpContext.
func (ctx *httpHeaders) OnHttpResponseHeaders(numHeaders int, endOfStream bool) types.Action {
	if err := proxywasm.SetHttpResponseHeader("hello", "world"); err != nil {
		proxywasm.LogCriticalf("failed to set response header: %v", err)
	}
	return types.ActionContinue
}

// Override DefaultHttpContext.
func (ctx *httpHeaders) OnHttpStreamDone() {
	proxywasm.LogInfof("%d finished", ctx.contextID)
}

runtime-config.json

{
  "type": "envoy_proxy",
  "abiVersions": ["v0-4689a30309abf31aee9ae36e73d34b1bb182685f", "v0.2.1"],
  "config": {
    "rootIds": [
      "root_id"
    ]
  }
}

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions