Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use the route filter metadata #284

Open
Brunomachadob opened this issue May 17, 2022 · 3 comments
Open

Unable to use the route filter metadata #284

Brunomachadob opened this issue May 17, 2022 · 3 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@Brunomachadob
Copy link

Brunomachadob commented May 17, 2022

Describe the bug / error

I'm trying to query the route filter metadata, using the GetProperty function, based on the docs: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/attributes

The problem is that I can't get the values I would like from it, using the format I was expecting it to be :{"route_metadata", "envoy.lua", "authorization"} or {"route_metadata", "envoy", "lua", "authorization"}.
Just as a sanity check, {"request", "path"} works as expected.

If I query for the root route_metadata I get an weird string representation.
From the docs, I believe that should be a map or structured values are converted to a sequence of pairs recursively. but apparently it is none of those. I've tried unmarshal the bytes to a map, also without success.

Please check the code and logs bellow.

Would this be a bug or maybe I'm doing something wrong?

What is your Envoy/Istio version?

Tested with Envoy 1.17 and 1.22

What is the SDK version?

v0.18.0

What is your TinyGo version?

tinygo version 0.23.0 darwin/amd64 (using go version go1.17.2 and LLVM version 14.0.0)

URL or snippet of your code including Envoy configuration

routes:
- match:
    prefix: "/"
  route:
    cluster: mockserver
  metadata:
    filter_metadata:
      envoy.lua:
        authorization:
          - TOKEN
func (ctx *httpContext) OnHttpRequestHeaders(numHeaders int, endOfStream bool) types.Action {
	proxywasm.LogInfo("OnHttpRequestHeaders")

	fieldsToTest := [][]string {
		{"request", "path"},
		{"route_metadata"},
		{"metadata"},
		{"route_metadata", "envoy.lua"},
		{"route_metadata", "envoy.lua", "authorization"},
		{"route_metadata.envoy.lua.authorization"},
	}

	for _, field := range fieldsToTest {
		value, err := proxywasm.GetProperty(field)

		if err != nil {
			proxywasm.LogErrorf("failure: %s", field)
		} else {
			proxywasm.LogInfof("success: %s=%s", field, value)
		}
	}

	return types.ActionContinue
}

Additional context (Optional)

Logs:

proxy_1         | [2022-05-17 18:20:00.633][18][info][wasm] [source/extensions/common/wasm/context.cc:1170] wasm log my_vm: OnHttpRequestHeaders
proxy_1         | [2022-05-17 18:20:00.633][18][info][wasm] [source/extensions/common/wasm/context.cc:1170] wasm log my_vm: success: [request path]=/test
proxy_1         | [2022-05-17 18:20:00.634][18][info][wasm] [source/extensions/common/wasm/context.cc:1170] wasm log my_vm: success: [route_metadata]=
proxy_1         | +
proxy_1         |       envoy.lua
proxy_1         | 
authorization   | 
             2  
proxy_1         | TOKEN
proxy_1         | [2022-05-17 18:20:00.634][18][info][wasm] [source/extensions/common/wasm/context.cc:1170] wasm log my_vm: success: [metadata]=
proxy_1         | [2022-05-17 18:20:00.634][18][error][wasm] [source/extensions/common/wasm/context.cc:1176] wasm log my_vm: failure: [route_metadata envoy.lua]
proxy_1         | [2022-05-17 18:20:00.634][18][error][wasm] [source/extensions/common/wasm/context.cc:1176] wasm log my_vm: failure: [route_metadata envoy.lua authorization]
proxy_1         | [2022-05-17 18:20:00.634][18][error][wasm] [source/extensions/common/wasm/context.cc:1176] wasm log my_vm: failure: [route_metadata.envoy.lua.authorization]

@mathetake mathetake added help wanted Extra attention is needed question Further information is requested labels May 20, 2022
@mathetake
Copy link
Member

maybe you want to take a look at #310

@mathetake
Copy link
Member

as for the list types, I see that Envoy always returns NotFound, which I think is a bug of Envoy.

@Brunomachadob
Copy link
Author

Nice, thanks!
I'll take a look and test this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants