Skip to content

Support bootstrap configs in text proto format, and improve errors.#1593

Merged
mattklein123 merged 5 commits intoenvoyproxy:masterfrom
jmillikin-stripe:config-as-text-proto
Sep 5, 2017
Merged

Support bootstrap configs in text proto format, and improve errors.#1593
mattklein123 merged 5 commits intoenvoyproxy:masterfrom
jmillikin-stripe:config-as-text-proto

Conversation

@jmillikin-stripe
Copy link
Copy Markdown
Contributor

This commit allows .pb_text configs to be parsed as text, and improves
the parse failure error message to include (1) text or binary mode, and
(2) the message type being parsed.

I was trying to use the new --bootstrap-path flag to get away from
JSON so the config could have comments, and got stuck for a while before
realizing the protobuf was being parsed in binary mode.

This commit allows `.pb_text` configs to be parsed as text, and improves
the parse failure error message to include (1) text or binary mode, and
(2) the message type being parsed.

I was trying to use the new `--bootstrap-path` flag to get away from
JSON so the config could have comments, and got stuck for a while before
realizing the protobuf was being parsed in _binary_ mode.
@mattklein123 mattklein123 requested a review from htuch September 5, 2017 20:52
@mattklein123
Copy link
Copy Markdown
Member

@jmillikin-stripe will defer to @htuch but I thought there was some reason we didn't want to support text PB (vs. JSON/YAML). He can advise.

If we do stick with this we will need a test.

@htuch
Copy link
Copy Markdown
Member

htuch commented Sep 5, 2017

Yes, since text PB is not standardized (it's not even consistent across languages in some corner cases), we decided to use YAML as the standardized textual representation of proto. That said, this is a small PR to give us support for this, which might be useful in some test situation, so sure, why not. We won't be officially supporting it though.

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just add a simple test (preferably just in utility_test.cc, I don't want to change any of the integration tests from YAML or duplicate there).

@htuch
Copy link
Copy Markdown
Member

htuch commented Sep 5, 2017

BTW, text PB is super ugly for the opaque filter configs, take a look at https://gist.github.com/htuch/aa273c9bf01ba9c6b18353ec8799695e#file-listeners_generated-pb. JSON/YAML representations hide this.

htuch
htuch previously approved these changes Sep 5, 2017

envoy::api::v2::Bootstrap proto_from_file;
MessageUtil::loadFromFile(filename, proto_from_file);
EXPECT_TRUE(TestUtility::protoEqual(bootstrap, proto_from_file));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please also test the exception case with EXPECT_THROW_WITH_MESSAGE by passing a bogus .pb_text file.

htuch
htuch previously approved these changes Sep 5, 2017
@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

jmillikin-stripe commented Sep 5, 2017

OK, tests added.

Yes, since text PB is not standardized (it's not even consistent across languages in some corner cases)

As one datapoint: For proto3, text format consistency across {C++, Go, Python, Java} is Good Enough™ for what we'll be using it for, and has strong advantages over YAML (simpler semantics/grammar) and JSON (comments). It's also more practical to generate than binary protobufs for environments that can't easily have protoc plumbed into them.

@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

Dev experience note: Tests won't build on my MacOS machine because it's missing some Linux tools (realpath?), and won't build in a lyft/envoy-build container for...mysterious reasons:

WARNING: /src/bazel/repositories.bzl:24:5: 
WARNING: /src/bazel/repositories.bzl:25:5: Process terminated by signal 15; also encountered an error while attempting to retrieve output
WARNING: /src/bazel/repositories.bzl:26:5: External dep build exited with return code: 256
WARNING: /src/bazel/repositories.bzl:28:9:  External dependency build failed, check above log for errors and ensure all prerequisites at https://github.com/lyft/envoy/blob/master/bazel/README.md#quick-start-bazel-build-for-developers are met.

@htuch, I understand a lot of the current Bazel weirdness is due to constraints from fitting the Envoy build into Google's external infra. At some point I'd like to see if it could be simplified so it's easier to build dependencies in a more Bazel-y way.

@htuch
Copy link
Copy Markdown
Member

htuch commented Sep 5, 2017

@jmillikin-stripe we're open to improvements to the build, as long as they don't involve creating a parallel Bazel build system for external deps (e.g. our own custom injected BUILD files via new_git_repository for every dependency). That was the state we started in earlier this year, and it was hard to maintain and had questionable build products (none of the tests for these dependencies were run with the hacked up BUILD files).

A pure Bazel dependency tree would be amazing, but I think it's a bit of a long term goal, given that dependencies seem to keep growing and very few projects are Bazel native.

That said, if we could move some parts out of the recursive make step to Bazel for dependencies where there is native Bazel support already (e.g. BoringSSL), which you previously expressed interest in, definitely open to that. We should have a better CI setup soon without the Travis resource limits, so that would open up the opportunity to having less done in prebuilts in CI.

@mattklein123 mattklein123 merged commit ca8572e into envoyproxy:master Sep 5, 2017
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: It looks like Bazel doesn't pick up the credentials env
  variable if it is already running. Unfortunately, there isn't an easy
  way to test this hypothesis without merging a commit to main.
Risk Level: LOW
Testing: N/A

Signed-off-by: Ulf Adams <ulf@engflow.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: It looks like Bazel doesn't pick up the credentials env
  variable if it is already running. Unfortunately, there isn't an easy
  way to test this hypothesis without merging a commit to main.
Risk Level: LOW
Testing: N/A

Signed-off-by: Ulf Adams <ulf@engflow.com>
Signed-off-by: JP Simard <jp@jpsim.com>
mathetake pushed a commit that referenced this pull request Mar 3, 2026
**Description**

This PR create a benchmark test for AIGW withe diffrent
`mcp-session-encryption-iterations`

Run this benchmark with following:

```console
go test -timeout=15m -run='^$$' -bench=. -benchmem -benchtime=1x ./tests/bench/...
2025/12/03 13:50:12 starting DUMB MCP Streamable-HTTP server on :8080 at /mcp
goos: darwin
goarch: arm64
pkg: github.com/envoyproxy/ai-gateway/tests/bench
cpu: Apple M1 Pro
BenchmarkMCP/BaseLine-10                       1          31305583 ns/op           49736 B/op        720 allocs/op
BenchmarkMCP/Iterations_100-10                 1           1394125 ns/op           22640 B/op        300 allocs/op
PASS
ok      github.com/envoyproxy/ai-gateway/tests/bench    5.394s
```


~~This result that the default `SessionCrypto` cost a lot, we'd better
improve it or change the default setting.~~

cc @nacx

---------

Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: Ignasi Barrera <nacx@apache.org>
Co-authored-by: Ignasi Barrera <nacx@apache.org>
Co-authored-by: Ignasi Barrera <ignasi@tetrate.io>
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.

3 participants