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

api: make any serialization stable for go #6241

Merged
merged 1 commit into from
Mar 11, 2019

Conversation

kyessenov
Copy link
Contributor

@kyessenov kyessenov commented Mar 11, 2019

Description: Using proto.MarshalAny results in unstable output due to non-deterministic map ordering. This in turn causes Envoy's diff to reload a config since the hash of the structure changes.
Enable stable marshaler for gogoproto to avoid this problem. See #6252
Risk Level: low
Testing: n/a
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Kuat Yessenov <kuat@google.com>
@kyessenov
Copy link
Contributor Author

The list of affected protos was found using git grep -l "map<" -- api/

@kyessenov
Copy link
Contributor Author

kyessenov commented Mar 11, 2019

/cc @htuch
This is likely the cause of CPU spikes with a repeated push of the same config due to non-deterministic proto serialization.

I don't have rights to re-trigger ASAN build.

@htuch htuch self-assigned this Mar 11, 2019
@htuch
Copy link
Member

htuch commented Mar 11, 2019

@kyessenov how does this get fixed in non-Go languages?

@kyessenov
Copy link
Contributor Author

@htuch That's a good question. The spec is deliberately unclear (https://developers.google.com/protocol-buffers/docs/proto#maps-features).

C++ has a magic key to sort maps https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/io/coded_stream.h#L856. Other implementations probably have some other mechanisms for stable marshaling.

@kyessenov kyessenov changed the title api: make any serialization stable api: make any serialization stable for go Mar 11, 2019
@duderino
Copy link

@PiotrSikora @htuch @lizan We'd love to get this into Istio 1.1. In fact we really can't ship Istio 1.1 without it.

@htuch
Copy link
Member

htuch commented Mar 11, 2019

@duderino Ack, just want to make sure we have a clear idea of whether this will be a long term fix. @kyessenov as long as this is stable for C++ at least, then I think we're all good; the main issue I wonder about is Envoy itself doing inconsistent hashing (didn't we have some upstream issue filed on this?). Should we file issues with java-control-plane? Maybe a master issue in the Envoy repo to track all work/languages and link to this in the commit message?

@kyessenov
Copy link
Contributor Author

Ref #6252

@htuch
Copy link
Member

htuch commented Mar 11, 2019

@kyessenov can you update the top comment/commit message in the GH UX with the updated reference? Thanks.

@htuch htuch merged commit 15a19b9 into envoyproxy:master Mar 11, 2019
@duderino
Copy link

thank you for the quick review and merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants