Skip to content

Commit

Permalink
Fix a bug in opaque config change and test it out (envoyproxy#182)
Browse files Browse the repository at this point in the history
* Fix a bug and test it out

* Update filter type

* Update README.md
  • Loading branch information
kyessenov authored Mar 17, 2017
1 parent 531cfa0 commit 95535f5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 32 deletions.
39 changes: 16 additions & 23 deletions src/envoy/mixer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,29 @@ 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:

```
"filters": [
"type": "both",
"type": "decoder",
"name": "mixer",
"config": {
"mixer_server": "${MIXER_SERVER}",
"attributes" : {
"mixer_attributes" : {
"attribute_name1": "attribute_value1",
"attribute_name2": "attribute_value2"
},
"forward_attributes" : {
"attribute_name1": "attribute_value1",
"attribute_name2": "attribute_value2"
}
Expand All @@ -74,26 +77,16 @@ This filter will intercept all HTTP requests and call Mixer. Here is its config:

Notes:
* mixer_server is required
* attributes: these attributes will be send to the mixer
* mixer_attributes: these attributes will be send to the mixer
* forward_attributes: these attributes will be forwarded to the upstream istio/proxy.

### *forward_attribute* HTTP filter:

This filer will forward attributes 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:

```
"filters": [
"type": "decoder",
"name": "forward_attribute",
"config": {
"attributes": {
"attribute_name1": "attribute_value1",
"attribute_name2": "attribute_value2"
}
"opaque_config": {
"mixer_control": "on",
"mixer_forward": "off"
}
```

Notes:
* attributes: these attributes will be forwarded to the upstream istio/proxy.



This config reverts the behavior by sending requests to mixer server but not forwarding any attributes.
15 changes: 10 additions & 5 deletions src/envoy/mixer/envoy.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
{
"timeout_ms": 0,
"prefix": "/",
"cluster": "service1"
"cluster": "service1",
"opaque_config": {
"mixer_control": "on",
"mixer_forward": "off"
}
}
]
}
Expand All @@ -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"
}
Expand Down Expand Up @@ -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"
}
Expand Down
6 changes: 2 additions & 4 deletions src/envoy/mixer/http_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 95535f5

Please sign in to comment.