Skip to content

Update Envoy SHA to 07-12. - #3395

Merged
istio-testing merged 6 commits into
istio:masterfrom
bianpengyuan:update-sha-0630
Jul 12, 2021
Merged

istio-testing merged 6 commits into
istio:masterfrom
bianpengyuan:update-sha-0630

Conversation

@bianpengyuan

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

@bianpengyuan
bianpengyuan requested a review from a team July 1, 2021 03:17
@google-cla google-cla Bot added the cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. label Jul 1, 2021
@istio-testing istio-testing added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 1, 2021
@kyessenov

Copy link
Copy Markdown
Contributor

@bianpengyuan
bianpengyuan requested a review from a team July 1, 2021 03:56
@istio-policy-bot

Copy link
Copy Markdown

🤔 🐛 You appear to be fixing a bug in Go code, yet your PR doesn't include updates to any test files. Did you forget to add a test?

Courtesy of your friendly test nag.

@istio-testing istio-testing added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 1, 2021
@bianpengyuan

Copy link
Copy Markdown
Contributor Author

@kyessenov I am not sure how TestStackdriverPayloadGateway ever worked. This is the important part of the failure log: https://gist.github.com/bianpengyuan/f35002b956375179fa22dbee86d6219f. The client log entry misses destination workload metadata.

I look at the test, it simulates a middle proxy with both inbound and outbound listener configured without metadata exchange, but how does server/client access log ever gets peer metadata? Is the dynamic metadata somehow preserved across streams?

@kyessenov

Copy link
Copy Markdown
Contributor

@bianpengyuan I think there is metadata exchange but they are both installed in the same proxy so source and destination are the same? Stream metadata could be preserved, it depends on how we configured it. I think it should be per-request now but it's been awhile I looked into it.

@bianpengyuan

Copy link
Copy Markdown
Contributor Author

@kyessenov Ah yeah sorry, misread the code. Turns out the MX filter always consider itself outbound regardless of which listener it is on, and it happens after envoyproxy/envoy@5a8f89a.

@mathetake Could you please take a look? metadata exchange filter get direction information with property API:

if (getValue({"listener_direction"}, &direction)) {
. After that change, if both inbound and outbound listeners are configured, metadata exchange filters will just pick one of them to get listener information.

@mathetake

Copy link
Copy Markdown
Member

OK let me take a look in a few days

@mathetake

Copy link
Copy Markdown
Member

ok it looks like the test has depended on the bag I fixed in that PR.

When I looked thorough the log, I see that the exactly the same configuration both for inbound/outbound mx filter:

outbound

      - name: mx_outbound162
        typed_config:
          "@type": type.googleapis.com/udpa.type.v1.TypedStruct
          type_url: envoy.extensions.filters.http.wasm.v3.Wasm
          value:
            config:
              vm_config:
                runtime: envoy.wasm.runtime.null
                code:
                  local: { inline_string: "envoy.wasm.metadata_exchange" }
                allow_precompiled: true
              configuration:
                "@type": "type.googleapis.com/google.protobuf.StringValue"
                value: |
                  { "max_peer_cache_size": 20 }

inbound

      - name: mx_inbound162
        typed_config:
          "@type": type.googleapis.com/udpa.type.v1.TypedStruct
          type_url: envoy.extensions.filters.http.wasm.v3.Wasm
          value:
            config:
              vm_config:
                runtime: envoy.wasm.runtime.null
                code:
                  local: { inline_string: "envoy.wasm.metadata_exchange" }
                allow_precompiled: true
              configuration:
                "@type": "type.googleapis.com/google.protobuf.StringValue"
                value: |
                  { "max_peer_cache_size": 20 }

which results in using the same plugin first created. This is the expected behavior.

I would recommend to set different root_id or vm_id for each of them, and believe that would fix the test.

@mathetake

Copy link
Copy Markdown
Member

^ cc @PiotrSikora

@bianpengyuan

Copy link
Copy Markdown
Contributor Author

I would recommend to set different root_id or vm_id for each of them, and believe that would fix the test.

@mathetake we originally had separated root_id/vm_id for inbound and outbound MX filters, in order to get the correct listener direction. Current behavior was considered as a "bug" and fixed, so that Wasm filter can get the listener context that it is on. It feels unnecessary to have different root / VM to just differentiate listener direction. There can be other listener properties, and I don't think we want to have different root context for each of them? It might be fine for us, but likely this will be surprised to the Wasm filter developers.

@mathetake

Copy link
Copy Markdown
Member

It feels unnecessary to have different root / VM to just differentiate listener direction. There can be other listener properties, and I don't think we want to have different root context for each of them? It might be fine for us, but likely this will be surprised to the Wasm filter developers.

yeah actually it is unnecessary if you use getProperty on stream context, then this should work correctly without setting vm_id or whatever. But the point is that mx filter plugin uses getProperty in the constructor of RootContext, which is only called once the plugin handle is created, and cache it:

direction_ = ::Wasm::Common::getTrafficDirection();

This is the root cause here. (stackdriver also uses getProperty in ::configure so same goes for it.)

This is by the original design of native Proxy-Wasm filters that a single in-VM plugin can be used at multiple extension points of the host implementation. But yeah we should reconsider this "original" behavior since as you said this is confusing and error-prone. Please refer to @PiotrSikora's comment here proxy-wasm/proxy-wasm-cpp-host#175 (comment)

@mathetake

Copy link
Copy Markdown
Member

ah - I misread the code, getTrafficDirection is called on each stream context.. seems weird.

@mathetake

Copy link
Copy Markdown
Member

update: successfully reproduced with Go SDK + a small Envoy config - dig into now.

@mathetake

mathetake commented Jul 6, 2021 •

Copy link
Copy Markdown
Member

OK I found the root cause which has existed since the beginning and just been caught and surfaced here due to my bug fix in that PR. The problem is much more complex than I expected. anyway thanks for reporting! now working on a fix.

@mathetake

Copy link
Copy Markdown
Member

So I raised a PR in Envoy envoyproxy/envoy#17243 . It was much more complex than I thought, and I think it's going to take some time to land. Thanks.

@kyessenov

Copy link
Copy Markdown
Contributor

@mathetake We have several fixes after the Wasm change that need to land. Do you think we need a deprecation flag to guard your change or we can get your fix PR soon?

@mathetake

Copy link
Copy Markdown
Member

I think the fix can get merged soon though the stackdriver extension needs to be revised accordingly - I see that it caches the direction in root context: https://github.com/istio/proxy/blob/master/extensions/stackdriver/stackdriver.cc#L379. But it all depends on how @PiotrSikora review the PR.

@istio-testing istio-testing added the needs-rebase Indicates a PR needs to be rebased before being merged label Jul 12, 2021
lizan pushed a commit to envoyproxy/envoy that referenced this pull request Jul 12, 2021
This is the follow up on #16795.

## Bug description

If the same plugin/rootcontext is shared across multiple listeners, then there is a race in listener information.

Before  #16795,  this was not a problem  for stream contexts since given listener information is from *where* it is created (`Plugin: plugin_` member created in the factory instance) https://github.com/envoyproxy/envoy/pull/16795/files#diff-90e133f83d91e5c22d1f7c7e8c0cf8017536a23765978bf81c7efd0482be0d81L43
But after that being merged, the `Plugin` passed to stream context constructor is the one from `PluginHandle::plugin()` which is potentially shared across multiple listeners.

For root contexts, this has been a problem since the beginning because the root context has been already potentially shared across multiple listeners, and pointing to the listener's info which is created first.


## Change in this PR

Combined with proxy-wasm/proxy-wasm-cpp-host#178, we explicitly include listener information into the plugin key so that if two plugins have different info to each other, different plugin instances will be created.

## Note

- Maybe we could drop the support for sharing 1 Plugin across multiple listeners (or filters), then this race condition would be resolved in a different way. I think it is worth discussion.
- This race is originally reported by Istio istio/proxy#3395 (comment)

Signed-off-by: Takeshi Yoneda <[email protected]>
@PiotrSikora

Copy link
Copy Markdown
Contributor

@bianpengyuan could you bump Envoy SHA? The Wasm fix was merged.

@bianpengyuan bianpengyuan changed the title Update Envoy SHA to 06-30. Update Envoy SHA to 07-12. Jul 12, 2021
@istio-testing istio-testing added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed needs-rebase Indicates a PR needs to be rebased before being merged size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 12, 2021
@bianpengyuan

Copy link
Copy Markdown
Contributor Author

/retest

@istio-testing
istio-testing merged commit 0537846 into istio:master Jul 12, 2021
leyao-daily pushed a commit to leyao-daily/envoy that referenced this pull request Sep 30, 2021
)

This is the follow up on envoyproxy#16795.

## Bug description

If the same plugin/rootcontext is shared across multiple listeners, then there is a race in listener information.

Before  envoyproxy#16795,  this was not a problem  for stream contexts since given listener information is from *where* it is created (`Plugin: plugin_` member created in the factory instance) https://github.com/envoyproxy/envoy/pull/16795/files#diff-90e133f83d91e5c22d1f7c7e8c0cf8017536a23765978bf81c7efd0482be0d81L43
But after that being merged, the `Plugin` passed to stream context constructor is the one from `PluginHandle::plugin()` which is potentially shared across multiple listeners.

For root contexts, this has been a problem since the beginning because the root context has been already potentially shared across multiple listeners, and pointing to the listener's info which is created first.


## Change in this PR

Combined with proxy-wasm/proxy-wasm-cpp-host#178, we explicitly include listener information into the plugin key so that if two plugins have different info to each other, different plugin instances will be created.

## Note

- Maybe we could drop the support for sharing 1 Plugin across multiple listeners (or filters), then this race condition would be resolved in a different way. I think it is worth discussion.
- This race is originally reported by Istio istio/proxy#3395 (comment)

Signed-off-by: Takeshi Yoneda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants