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

Converting envoy configs to V2 #2957

Merged
merged 45 commits into from
Aug 16, 2018
Merged

Converting envoy configs to V2 #2957

merged 45 commits into from
Aug 16, 2018

Conversation

srikailash
Copy link
Contributor

@srikailash srikailash commented Mar 31, 2018

This is work in progress PR for converting envoy configs to v2. (#2139)
Signed-off-by: sri kailash [email protected]

title: Converting envoy configs to v2.

Description:
added yaml files for envoy_front_proxy.template, envoy_double_proxy.template, envoy_router.template, routing_helper.template and added a temporary generate_v2_config file which will be removed later on.
Used json2yaml.com to transform json files to yaml.

Risk Level: Low

Testing:
Need to test with generated configs. this is under todo list.

Docs Changes:
TODO

TODO:

  1. Add v2 config for envoy_service_to_service.template.yaml
  2. Need to clean up formatting issues for generated configs
  3. Test the configs generated.

@srikailash srikailash changed the title Migrating envoy configs to V2 Converting envoy configs to V2 Mar 31, 2018
@mattklein123
Copy link
Member

@srikailash this looks on the right track. Can you ping us when this is ready for review? (Basically we just want to replace all the JSON stuff with pure v2 and get similar configs).

@ccaraman
Copy link
Contributor

ccaraman commented Apr 4, 2018

@srikailash Please merge master. That has a fix for the failing ipv6 tests.

@srikailash
Copy link
Contributor Author

@ccaraman done, thanks.
@mattklein123, Sure, will ping here when this is ready for review.

@@ -0,0 +1,65 @@
#Import necessary functions from Jinja2 module
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will remove this file before final merging.

@srikailash
Copy link
Contributor Author

@mattklein123 , this is ready for review.
I tested generated yaml configs with json converted to yaml configs and looked right to me.
Need to trim some extra lines being generated. Thanks!

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Nice!!!

@junr03 can you review as this is related to what you have done internally?

@srikailash we should remove the v1 config generators as part of this change. Can you also make sure the new files are being config tested as part of tests? Thanks!!!

@srikailash
Copy link
Contributor Author

@mattklein123 , please elaborate on this 'Can you also make sure the new files are being config tested as part of tests?'. Does that mean starting envoy with generated yaml and manually testing? Thanks!

@mattklein123
Copy link
Member

@srikailash take a look at https://github.com/envoyproxy/envoy/blob/master/configs/BUILD. We test all the configs that are output by configgen. So the result of this change should be to delete all the JSON output and instead test all of the YAML output v2 configs.

Copy link
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

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

@srikailash thanks for doing this! I got you started with all my comments for one of the templates. However, what I noticed is that you did a 1:1 translation of the templates from JSON to yaml. Unfortunately the transition from v1 to v2 is also structural and a lot of the configuration is different.

I gave you all the pointers I found in one of the templates. Please take that, and the docs for the v2 format https://www.envoyproxy.io/docs/envoy/latest/api-v2/api to rewrite the remaining templates. I can take a look again after you go through them.

@@ -0,0 +1,110 @@
---
{% macro listener(address,ssl,proxy_proto) -%}
- address: "{{ address }}"
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Needs to look akin to:

- address:
    socket_address:
      address: {{ address }}
      protocol: {{ protocol }}
      port_value: {{ port }}

{% macro listener(address,ssl,proxy_proto) -%}
- address: "{{ address }}"
{% if ssl -%}
ssl_context:
Copy link
Member

Choose a reason for hiding this comment

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

this field has changed a lot. It now hangs of off the filter_chains field and its organization has changed quite a bit: https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/auth/cert.proto#envoy-api-msg-auth-downstreamtlscontext

private_key_file: certs/serverkey.pem
{% endif -%}
{% if proxy_proto -%}
use_proxy_proto: true
Copy link
Member

Choose a reason for hiding this comment

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

this also hangs off of filter_chains

{% if proxy_proto -%}
use_proxy_proto: true
{% endif -%}
filters:
Copy link
Member

Choose a reason for hiding this comment

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

filters:
- name: http_connection_manager
config:
codec_type: auto
Copy link
Member

Choose a reason for hiding this comment

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

values that are enums should be all upper case. ex: AUTO

cluster_manager:
clusters:
- name: statsd
connect_timeout_ms: 250
Copy link
Member

Choose a reason for hiding this comment

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

same as comment above about duration fields

- name: statsd
connect_timeout_ms: 250
type: static
lb_type: round_robin
Copy link
Member

Choose a reason for hiding this comment

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

the field name is now lb_policy. enums need to be all upper case

type: static
lb_type: round_robin
hosts:
- url: tcp://127.0.0.1:8125
Copy link
Member

Choose a reason for hiding this comment

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

lb_type: round_robin
features: http2
max_requests_per_connection: 25000
ssl_context:
Copy link
Member

Choose a reason for hiding this comment

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

- front-proxy.yourcompany.net
hosts:
- url: tcp://front-proxy.yourcompany.net:9400
- name: lightstep_saas
Copy link
Member

Choose a reason for hiding this comment

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

both this, and the above cluster have the same comments as the statsd cluster

@srikailash
Copy link
Contributor Author

@junr03 ,thanks for detailed comments. Will let you know after updating.

@srikailash
Copy link
Contributor Author

@junr03 mind having a quick look at above commit changes.
TODO: need to update access_log, tls related configs.(probably need some help regarding adding tls config, gonna read that up again).
Thanks!

Copy link
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

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

@srikailash looking better. There are still some problems, but heading in the right direction. Let me know when you have updated

protocol:
address: tcp://127.0.0.1
port_value: 9901
named_port:
Copy link
Member

Choose a reason for hiding this comment

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

this field and the two below are not needed

access_log_path: "var/log/envoy/admin_access.log"
address:
socket_address:
protocol:
Copy link
Member

Choose a reason for hiding this comment

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

protocol here is TCP

address:
socket_address:
protocol:
address: tcp://127.0.0.1
Copy link
Member

Choose a reason for hiding this comment

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

the address should just be 127.0.0.1

runtime:
symlink_root: /srv/runtime_data/current
subdirectory: envoy
override_subdirectory: envoy_override
Copy link
Member

Choose a reason for hiding this comment

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

nit: not sure why, but there are many fields like this that have two spaces, can you fix?

type: STATIC
connect_timeout: 0.25s
lb_policy: ROUND_ROBIN
hosts:
Copy link
Member

Choose a reason for hiding this comment

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

This field is an array

lb_policy: ROUND_ROBIN
hosts:
socket_address:
address: tcp://127.0.0.1
Copy link
Member

Choose a reason for hiding this comment

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

same comment as above on the address. The protocol should be in its own field, and the address part should only be the 127.0.0.1 part

socket_address:
address: tcp://127.0.0.1
port: 8125
- name: backhaul
Copy link
Member

Choose a reason for hiding this comment

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

same comments as the ones above for this cluster and the one below

@srikailash
Copy link
Contributor Author

@junr03, fixed problems mentioned by you. please take a look.

@junr03
Copy link
Member

junr03 commented Apr 20, 2018

@srikailash do you mind solving the CI issues first, then I'll take a look at the whole change. Thanks!

configs/BUILD Outdated
]),
external_deps = ["jinja2"],
external_deps = ["jinja2", "yaml"],
Copy link
Contributor Author

@srikailash srikailash Apr 22, 2018

Choose a reason for hiding this comment

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

@junr03 should this line be enough to import yaml in configgen.py? I see tests are failing because of "import yaml" in configgen.py. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

@srikailash you need to add it to the python deps like jinja2. Take a look at how that is done

# Python dependencies. If these become non-trivial, we might be better off using a virtualenv to
, ,
com_github_pallets_jinja = dict(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@junr03, please have a quick look at (a87dfe1). //test/config_test:example_configs_test seems to be failing still.(pyyaml has a cmake build type) . Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@junr03, friendly ping. :)

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, didn't see this comment before. I'm away at a conference. Do you mind going to the #bazel channel on the envoy slack to ask for advice on this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@junr03, tried asking in #bazel channel and had some discussion with Kuat. Couldn't solve the issue. Any thoughts on how to fix this? Thanks!

name = "pyyaml",
actual = "@com_github_yaml_pyyaml//:pyyaml",
name = "yaml",
actual = "@com_github_yaml_pyyaml//:lib/yaml",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the actual name should be @com_github_yaml_pyyaml//:yaml. The external workspace binds only top-level names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kyessenov, thanks for checking. I guess that should be the directory after cloning from com_github_yaml_pyyaml defined in repository_locations.bzl. I made that change and couldn't fix build. Could be please take a look again? Thanks in advance!

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, This name resolves to the py_library in pyyaml.BUILD. You can rename that library to lib/yaml or use :yaml here, either way is fine, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kyessenov , changed with 5602eed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kyessenov, friendly ping. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, missed notifications :( Bazel stuff looks fine to me.

@junr03
Copy link
Member

junr03 commented May 15, 2018

@srikailash coming back to this. What do you need from us to move this forward? Should I do another review? Did we resolve all the bazel/build issues?

@srikailash
Copy link
Contributor Author

@junr03, thanks for checking this again. I need help with two things

  1. Need to fix importing yaml build issue
  2. Add ssl context to templates in v2 api.
    Regarding 1: tried asking in #bazel , had some discussion with kuat but couldn't fix it

@junr03
Copy link
Member

junr03 commented May 15, 2018

@jmillikin-stripe do you have a cycle to help @srikailash with his dependency issue?

@junr03
Copy link
Member

junr03 commented May 15, 2018

@srikailash for 2. DM me on the envoy slack and we can iterate on that if you have specific questions

@kyessenov
Copy link
Contributor

Let me pull your fork and try out bazel build locally.

@kyessenov
Copy link
Contributor

Can you try this:

diff --git a/bazel/external/pyyaml.BUILD b/bazel/external/pyyaml.BUILD
index d4e8e1d..6e203e9 100644
--- a/bazel/external/pyyaml.BUILD
+++ b/bazel/external/pyyaml.BUILD
@@ -1,5 +1,6 @@
 py_library(
     name = "yaml",
     srcs = glob(["lib/yaml/**/*.py"]),
+    imports = ["lib"],
     visibility = ["//visibility:public"],
 )

@srikailash
Copy link
Contributor Author

@kyessenov, thanks for the fix. importing error is fixed, now it is for me to fix other tests.

@@ -15,7 +15,7 @@ TEST(ExampleConfigsTest, All) {
RELEASE_ASSERT(::getcwd(cwd, PATH_MAX) != nullptr);
RELEASE_ASSERT(::chdir(directory.c_str()) == 0);

EXPECT_EQ(26UL, ConfigTest::run(directory));
EXPECT_EQ(24UL, ConfigTest::run(directory));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will update this once other configs are up-to-date.

@zuercher
Copy link
Member

@srikailash is this ready for review again or are more changes forthcoming?

@srikailash
Copy link
Contributor Author

@zuercher i asked Jose for a review just to make sure it is in the right path, but yeah there are some updates that needs to be done in service_to_service template.

@zuercher
Copy link
Member

@srikailash Thanks for the update. Please give him a mention here when you're ready for another look.

@srikailash
Copy link
Contributor Author

@junr03, this is ready for review now.
I probably need help with following things:

  1. Add sds clusters to internal_cluster_definition in envoy_front_proxy.v2.template
  2. Add dynamic_resources to envoy_front_proxy
  3. Add access_log config with or_filters to service_to_service envoy
  4. Add rds to service_to_service envoy
    Thanks in advance!

@stale
Copy link

stale bot commented Jul 3, 2018

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Jul 3, 2018
@srikailash
Copy link
Contributor Author

Will update and reopen the PR. Thanks :)

@srikailash srikailash closed this Jul 4, 2018
@srikailash
Copy link
Contributor Author

srikailash commented Jul 28, 2018

Hello, building upstream envoy fails with

envoy/bazel/repositories.bzl:10:1: file '@bazel_tools//tools/cpp:windows_cc_configure.bzl' does not contain symbol 'setup_vc_env_vars'
ERROR: error loading package '': Extension file 'bazel/repositories.bzl' has errors
ERROR: error loading package '': Extension file 'bazel/repositories.bzl' has errors
INFO: Elapsed time: 0.187s
FAILED: Build did NOT complete successfully (0 packages loaded)
ERROR: Couldn't start the build. Unable to run tests

couldn't get a response in slack. please let me know how to resolve this blocker. Thanks

@dio
Copy link
Member

dio commented Jul 28, 2018

Hi @srikailash, what version of bazel do you use? Are you on osx or linux?

@srikailash
Copy link
Contributor Author

srikailash commented Jul 28, 2018

@dio , thanks and this is the version : 0.11.0-homebrew and i am on osx.

@dio
Copy link
Member

dio commented Jul 28, 2018

@srikailash I think it's worth to do brew upgrade bazel now 🙂.

@srikailash
Copy link
Contributor Author

@dio, build still fails with
External dependency build failed, check above log for errors and ensure all prerequisites at https://github.com/envoyproxy/envoy/blob/master/bazel/README.md#quick-start-bazel-build-for-developers are met. ERROR: /Users/sgandebathul/opensource/upstream_envoy/envoy/bazel/repositories.bzl:264:13: no such package '@envoy_deps//': External dep build failed and referenced by '//external:ares' ERROR: Analysis of target '//test/common/network:dns_impl_test' failed; build aborted: Analysis failed . How can i resolve that?

@srikailash
Copy link
Contributor Author

bazel run //tools:v1_to_bootstrap envoy_double_proxy.json fails to build on upstream with this error
no such package '@envoy_deps//': External dep build failed and referenced by '//external:tcmalloc_and_profiler' ERROR: Analysis of target '//tools:v1_to_bootstrap' failed; build aborted: Analysis failed.
@junr03 @dio how can i fix this?

@mattklein123
Copy link
Member

@srikailash can you please blow away your entire dev environment and setup from scratch along with having the most recent versions of all the packages? If it still doesn't work I would get in Slack and ask there either in the OSX room if you are using OSX or in the normal dev room if you are using Linux.

@srikailash
Copy link
Contributor Author

@mattklein123, tried with new dev environment. Still have the same issue.

@srikailash srikailash reopened this Aug 2, 2018
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Aug 2, 2018
Copy link
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

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

just a few more comments, thanks!

@@ -173,14 +173,21 @@ def _python_deps():
actual = "@com_github_pallets_jinja//:jinja2",
)
_repository_impl(
name = "com_github_yaml_pyyaml",
build_file = "@envoy//bazel/external:pyyaml.BUILD",
name = "com_github_apache_thrift",
Copy link
Member

Choose a reason for hiding this comment

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

I think this must be a merge problem, right?

runtime_key: access_log.access_error.duration
{% endif %}
config:
path: /var/log/envoy/access_error.log
Copy link
Member

Choose a reason for hiding this comment

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

These names are still off

- key: database
value: "{{ key }}"
{% endif %}
{% if not loop.last %}{% endif -%}
Copy link
Member

Choose a reason for hiding this comment

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

not needed.

cds_config:
api_config_source:
cluster_names:
- sds
Copy link
Member

Choose a reason for hiding this comment

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

this should be cds_cluster

Signed-off-by: sri kailash <[email protected]>
@srikailash
Copy link
Contributor Author

@junr03 , this is ready for another pass.

@mattklein123
Copy link
Member

@junr03 @danielhochman friendly ping PTAL. I would love to land this next week.

Copy link
Member

@junr03 junr03 left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, was coming back from vacation.

Alright, I can't see anything else missing here at plain sight, and we have gone through the due diligence of comparing with the conversion tool. I think we should check in. And if there are needed changes by the community deal with them in small PRs.

Thanks for your hard work here @srikailash

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Epic! Thank you!!!!!!! 💯

@mattklein123 mattklein123 merged commit 3d1325e into envoyproxy:master Aug 16, 2018
@srikailash
Copy link
Contributor Author

Thanks for merging and review process, this helped to learn about envoy more.

@junr03 junr03 mentioned this pull request Aug 16, 2018
4 tasks
snowp added a commit to snowp/envoy that referenced this pull request Aug 20, 2018
* origin/master: (34 commits)
  fuzz: fixes oss-fuzz: 9895 (envoyproxy#4189)
  docs: added developer docs for pprof/tcmalloc testing (envoyproxy#4194)
  fix sometimes returns response body to HEAD requests (envoyproxy#3985)
  admin: fix config dump order (envoyproxy#4197)
  thrift: allow translation between downstream and upstream protocols (envoyproxy#4136)
  Use local_info.node() instead of bootstrap.node() whenever possible (envoyproxy#4120)
  upstream: allow extension protocol options to be used with http filters (envoyproxy#4165)
  [thrift_proxy] Replace local HeaderMap with Http::HeaderMap[Impl] (envoyproxy#4169)
  docs: improve gRPC-JSON filter doc (envoyproxy#4184)
  stats: refactoring MetricImpl without strings (envoyproxy#4190)
  fuzz: coverage profile generation instructions. (envoyproxy#4193)
  upstream: rebuild cluster when health check config is changed (envoyproxy#4075)
  build: use clang-6.0. (envoyproxy#4168)
  thrift_proxy: introduce header transport (envoyproxy#4082)
  tcp: allow connection pool callers to store protocol state (envoyproxy#4131)
  configs: match latest API changes (envoyproxy#4185)
  Fix wrong mock function name. (envoyproxy#4187)
  Bump yaml-cpp so it builds with Visual Studio 15.8 (envoyproxy#4182)
  Converting envoy configs to V2 (envoyproxy#2957)
  Add timestamp to HealthCheckEvent definition (envoyproxy#4119)
  ...

Signed-off-by: Snow Pettersen <[email protected]>
wsh added a commit to wsh/envoy that referenced this pull request Oct 10, 2018
The format (and filenames) changed in envoyproxy#2957.

Signed-off-by: Will Hayworth <[email protected]>
mattklein123 pushed a commit that referenced this pull request Oct 10, 2018
The format (and filenames) changed in #2957.

Signed-off-by: Will Hayworth <[email protected]>
rshriram pushed a commit to rshriram/envoy that referenced this pull request Oct 30, 2018
…#1938)

This is far from finished, but it reduces memory usage by ~10%.

Pulling the following changes from github.com/envoyproxy/envoy:

c1cc68d stats: refactoring MetricImpl without strings (envoyproxy#4190)
36809d8 fuzz: coverage profile generation instructions. (envoyproxy#4193)
ba40cc9 upstream: rebuild cluster when health check config is changed (envoyproxy#4075)
05c0d52 build: use clang-6.0. (envoyproxy#4168)
01f403e thrift_proxy: introduce header transport (envoyproxy#4082)
564d256 tcp: allow connection pool callers to store protocol state (envoyproxy#4131)
3e1d643 configs: match latest API changes (envoyproxy#4185)
bc6a10c Fix wrong mock function name. (envoyproxy#4187)
e994c1c Bump yaml-cpp so it builds with Visual Studio 15.8 (envoyproxy#4182)
3d1325e Converting envoy configs to V2 (envoyproxy#2957)
8d0680f Add timestamp to HealthCheckEvent definition (envoyproxy#4119)
497efb9 server: handle non-EnvoyExceptions safely if thrown in constructor. (envoyproxy#4173)
6d6fafd config: strengthen validation for gRPC config sources. (envoyproxy#4171)
132302c fuzz: reduce log level when running under fuzz engine. (envoyproxy#4161)
7c04ac2 test: fix V6EmptyOptions in coverage with IPv6 enable (envoyproxy#4155)
1b2219b ci: remove deprecated bazel --batch option (envoyproxy#4166)
2db6a4c ci: update clang to version 6.0 in the Ubuntu build image. (envoyproxy#4157)
71152b7 ratelimit: Add ratelimit custom response headers (envoyproxy#4015)
3062874 ssl: make Ssl::Connection const everywhere (envoyproxy#4179)
706e262 Handle validation of non expiring tokens in jwt_authn filter (envoyproxy#4007)
f06e958 fuzz: tag trivial fuzzers with no_fuzz. (envoyproxy#4156)
27fb1d3 thrift_proxy: add service name matching to router implementation (envoyproxy#4130)
8c189a5 Make over provisioning factor configurable (envoyproxy#4003)
6c08fb4 Making test less flaky (envoyproxy#4149)
592775b fuzz: bare bones HCM fuzzer. (envoyproxy#4118)

For istio/istio#7912.

Signed-off-by: Piotr Sikora <[email protected]>
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.

8 participants