From 4630202260f7264acd74411122cb978aca46179c Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Thu, 16 Mar 2017 18:09:02 -0700 Subject: [PATCH 1/3] Fix a bug and test it out --- src/envoy/mixer/README.md | 35 +++++++++-------------------- src/envoy/mixer/envoy.conf.template | 15 ++++++++----- src/envoy/mixer/http_filter.cc | 6 ++--- 3 files changed, 22 insertions(+), 34 deletions(-) diff --git a/src/envoy/mixer/README.md b/src/envoy/mixer/README.md index d7d39f30e03..1135a178bf6 100644 --- a/src/envoy/mixer/README.md +++ b/src/envoy/mixer/README.md @@ -46,15 +46,14 @@ This Proxy will use Envoy and talk to Mixer server. * Then issue HTTP request to proxy. ``` + # request to server-side proxy curl http://localhost:9090/echo -d "hello world" + # request to client-side proxy that gets sent to server-side proxy + curl http://localhost:7070/echo -d "hello world" ``` ## How to configurate HTTP filters -This module has two HTTP filters: -1. mixer filter: intercept all HTTP requests, call the mixer. -2. forward_attribute filter: Forward attributes to the upstream istio/proxy. - ### *mixer* filter: This filter will intercept all HTTP requests and call Mixer. Here is its config: @@ -65,35 +64,21 @@ This filter will intercept all HTTP requests and call Mixer. Here is its config: "name": "mixer", "config": { "mixer_server": "${MIXER_SERVER}", - "attributes" : { + "mixer_attributes" : { "attribute_name1": "attribute_value1", "attribute_name2": "attribute_value2" - } - } -``` - -Notes: -* mixer_server is required -* attributes: these attributes will be send to the mixer - -### *forward_attribute* HTTP filter: - -This filer will forward attributes to the upstream istio/proxy. - -``` - "filters": [ - "type": "decoder", - "name": "forward_attribute", - "config": { - "attributes": { + }, + "forward_attributes" : { "attribute_name1": "attribute_value1", "attribute_name2": "attribute_value2" - } + } } ``` Notes: -* attributes: these attributes will be forwarded to the upstream istio/proxy. +* mixer_server is required +* mixer_attributes: these attributes will be send to the mixer +* forward_attributes: these attributes will be forwarded to the upstream istio/proxy. diff --git a/src/envoy/mixer/envoy.conf.template b/src/envoy/mixer/envoy.conf.template index c5377632388..86aa0e1dc33 100644 --- a/src/envoy/mixer/envoy.conf.template +++ b/src/envoy/mixer/envoy.conf.template @@ -19,7 +19,11 @@ { "timeout_ms": 0, "prefix": "/", - "cluster": "service1" + "cluster": "service1", + "opaque_config": { + "mixer_control": "on", + "mixer_forward": "off" + } } ] } @@ -32,11 +36,11 @@ ], "filters": [ { - "type": "both", + "type": "decoder", "name": "mixer", "config": { "mixer_server": "${MIXER_SERVER}", - "attributes": { + "mixer_attributes": { "target.uid": "POD222", "target.namespace": "XYZ222" } @@ -85,9 +89,10 @@ "filters": [ { "type": "decoder", - "name": "forward_attribute", + "name": "mixer", "config": { - "attributes": { + "mixer_server": "${MIXER_SERVER}", + "forward_attributes": { "source.uid": "POD11", "source.namespace": "XYZ11" } diff --git a/src/envoy/mixer/http_filter.cc b/src/envoy/mixer/http_filter.cc index 59a459e166c..d6ca93e2bb5 100644 --- a/src/envoy/mixer/http_filter.cc +++ b/src/envoy/mixer/http_filter.cc @@ -263,10 +263,8 @@ class Instance : public Http::StreamDecoderFilter, StreamDecoderFilterCallbacks& callbacks) override { Log().debug("Called Mixer::Instance : {}", __func__); decoder_callbacks_ = &callbacks; - if (!mixer_disabled()) { - decoder_callbacks_->addResetStreamCallback( - [this]() { state_ = Responded; }); - } + decoder_callbacks_->addResetStreamCallback( + [this]() { state_ = Responded; }); } void completeCheck(const Status& status) { From 08283cbb4a97610069cc397bb4fd8eda56db4ce5 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Thu, 16 Mar 2017 18:18:00 -0700 Subject: [PATCH 2/3] Update filter type --- src/envoy/mixer/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/envoy/mixer/README.md b/src/envoy/mixer/README.md index 1135a178bf6..8186e405089 100644 --- a/src/envoy/mixer/README.md +++ b/src/envoy/mixer/README.md @@ -60,7 +60,7 @@ This filter will intercept all HTTP requests and call Mixer. Here is its config: ``` "filters": [ - "type": "both", + "type": "decoder", "name": "mixer", "config": { "mixer_server": "${MIXER_SERVER}", From 935d0ab9f41a52bf40aba71b44188ada7b772595 Mon Sep 17 00:00:00 2001 From: Kuat Yessenov Date: Thu, 16 Mar 2017 18:19:47 -0700 Subject: [PATCH 3/3] Update README.md --- src/envoy/mixer/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/envoy/mixer/README.md b/src/envoy/mixer/README.md index 8186e405089..4e30eb08f56 100644 --- a/src/envoy/mixer/README.md +++ b/src/envoy/mixer/README.md @@ -80,5 +80,13 @@ Notes: * mixer_attributes: these attributes will be send to the mixer * forward_attributes: these attributes will be forwarded to the upstream istio/proxy. +By default, mixer filter forwards attributes and does not invoke mixer server. You can customize this behavior per HTTP route by supplying an opaque config: +``` + "opaque_config": { + "mixer_control": "on", + "mixer_forward": "off" + } +``` +This config reverts the behavior by sending requests to mixer server but not forwarding any attributes.