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

formatter: support for virtual host metadata #34958

Merged
merged 8 commits into from
Jul 11, 2024

Conversation

mathetake
Copy link
Member

Commit Message: formatter: support for virtual host metadata
Additional Description:
This enables the access to the virtual host metadata introduced in #30175 from formatter.

Risk Level: low
Testing: : unit test
Docs Changes: done.
Release Notes:
Platform Specific Features:
[Optional Fixes #Issue] #34900

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #34958 was opened by mathetake.

see: more, trace.

Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @abeyad
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #34958 was opened by mathetake.

see: more, trace.

@mathetake mathetake marked this pull request as ready for review June 27, 2024 21:51
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake
Copy link
Member Author

/retest

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake
Copy link
Member Author

Verify Examples job failure is irrelevant to this eg the same error on main https://github.com/envoyproxy/envoy/actions/runs/9708036595/job/26794181496

abeyad
abeyad previously approved these changes Jun 28, 2024
Copy link
Contributor

@abeyad abeyad left a comment

Choose a reason for hiding this comment

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

/lgtm api

@abeyad
Copy link
Contributor

abeyad commented Jun 28, 2024

/assign-from @envoyproxy/senior-maintainers

Copy link

@envoyproxy/senior-maintainers assignee is @RyanTheOptimist

🐱

Caused by: a #34958 (comment) was created by @abeyad.

see: more, trace.

Copy link
Contributor

@RyanTheOptimist RyanTheOptimist left a comment

Choose a reason for hiding this comment

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

Looks great. Is it possible to add an integration test which verifies this behavior?

@mathetake
Copy link
Member Author

thanks @RyanTheOptimist, added an integration test with access logger in 747b642

@RyanTheOptimist
Copy link
Contributor

thanks @RyanTheOptimist, added an integration test with access logger in 747b642

This is a good test, but I was hoping to see something in test/integration in which we see Envoy process an actual request. This test is TCP-proxy specific, but shows the idea. https://github.com/envoyproxy/envoy/blob/main/test/integration/tcp_proxy_integration_test.cc#L378

Would this be possible?

@mathetake
Copy link
Member Author

@RyanTheOptimist this formatter is an extension so that would require using envoy_extension_cc_test for say tcp_proxy_integration_test. Is that acceptable practice in general? (I am not knowledgeable on the extension visibility policy)

diff --git a/test/integration/BUILD b/test/integration/BUILD
index 5f643fb68c..4648bede8b 100644
--- a/test/integration/BUILD
+++ b/test/integration/BUILD
@@ -1743,13 +1743,16 @@ envoy_cc_test_library(
     hdrs = ["tcp_proxy_integration_test.h"],
 )
 
-envoy_cc_test(
+envoy_extension_cc_test(
     name = "tcp_proxy_integration_test",
     size = "large",
     srcs = ["tcp_proxy_integration_test.cc"],
     data = [
         "//test/config/integration/certs",
     ],
+    extension_names = [
+        "envoy.formatter.metadata",
+    ],
     tags = [
         "cpu:3",
     ],
@@ -1767,6 +1770,7 @@ envoy_cc_test(
         "//source/extensions/access_loggers/file:config",
         "//source/extensions/filters/network/common:factory_base_lib",
         "//source/extensions/filters/network/tcp_proxy:config",
+        "//source/extensions/formatter/metadata:config",
         "//source/extensions/load_balancing_policies/subset:config",
         "//source/extensions/transport_sockets/tls:config",
         "//test/mocks/runtime:runtime_mocks",

@mathetake
Copy link
Member Author

well this doesn't work as well -

vscode@mathetake-Venus-series:/workspaces/envoy$ bazel test --define wasm=none //test/integration:tcp_proxy_integration_test
ERROR: /workspaces/envoy/test/integration/BUILD:1750:24: in cc_test rule //test/integration:tcp_proxy_integration_test: target '//source/extensions/formatter/metadata:config' is not visible from target '//test/integration:tcp_proxy_integration_test'. Check the visibility declaration of the former target if you think the dependency is legitimate
ERROR: /workspaces/envoy/test/integration/BUILD:1750:24: Analysis of target '//test/integration:tcp_proxy_integration_test' failed
ERROR: Analysis of target '//test/integration:tcp_proxy_integration_test' failed; build aborted: 
INFO: Elapsed time: 0.938s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (605 packages loaded, 35042 targets configured)
ERROR: Couldn't start the build. Unable to run tests

@mathetake
Copy link
Member Author

so

diff --git a/source/extensions/formatter/metadata/BUILD b/source/extensions/formatter/metadata/BUILD
index 8d1bf6bf39..78a8e7d86b 100644
--- a/source/extensions/formatter/metadata/BUILD
+++ b/source/extensions/formatter/metadata/BUILD
@@ -23,6 +23,10 @@ envoy_cc_extension(
     name = "config",
     srcs = ["config.cc"],
     hdrs = ["config.h"],
+    extra_visibility = [
+        "//test:__subpackages__",
+    ],
     deps = [
         "//envoy/registry",
         "//source/extensions/formatter/metadata:metadata_lib",
diff --git a/test/integration/BUILD b/test/integration/BUILD
index 5f643fb68c..d5dd5ebc54 100644
--- a/test/integration/BUILD
+++ b/test/integration/BUILD
@@ -1767,6 +1767,7 @@ envoy_cc_test(
         "//source/extensions/access_loggers/file:config",
         "//source/extensions/filters/network/common:factory_base_lib",
         "//source/extensions/filters/network/tcp_proxy:config",
+        "//source/extensions/formatter/metadata:config",
         "//source/extensions/load_balancing_policies/subset:config",
         "//source/extensions/transport_sockets/tls:config",
         "//test/mocks/runtime:runtime_mocks",

ok so this is what we need. is this acceptable? @RyanTheOptimist

@RyanTheOptimist
Copy link
Contributor

so

diff --git a/source/extensions/formatter/metadata/BUILD b/source/extensions/formatter/metadata/BUILD
index 8d1bf6bf39..78a8e7d86b 100644
--- a/source/extensions/formatter/metadata/BUILD
+++ b/source/extensions/formatter/metadata/BUILD
@@ -23,6 +23,10 @@ envoy_cc_extension(
     name = "config",
     srcs = ["config.cc"],
     hdrs = ["config.h"],
+    extra_visibility = [
+        "//test:__subpackages__",
+    ],
     deps = [
         "//envoy/registry",
         "//source/extensions/formatter/metadata:metadata_lib",
diff --git a/test/integration/BUILD b/test/integration/BUILD
index 5f643fb68c..d5dd5ebc54 100644
--- a/test/integration/BUILD
+++ b/test/integration/BUILD
@@ -1767,6 +1767,7 @@ envoy_cc_test(
         "//source/extensions/access_loggers/file:config",
         "//source/extensions/filters/network/common:factory_base_lib",
         "//source/extensions/filters/network/tcp_proxy:config",
+        "//source/extensions/formatter/metadata:config",
         "//source/extensions/load_balancing_policies/subset:config",
         "//source/extensions/transport_sockets/tls:config",
         "//test/mocks/runtime:runtime_mocks",

ok so this is what we need. is this acceptable? @RyanTheOptimist

Hm. Good question. I have a vague recollection that we have a policy about this somehow. @alyssawilk can you clarify?

@alyssawilk
Copy link
Contributor

generally we request folks not add tests of extension functionality into "core" directories but instead have e2e tests in the extension directory. Otherwise we often break the build for folks who don't import a given extension

@mathetake
Copy link
Member Author

mathetake commented Jul 2, 2024

thank you for clarifying. So I think my last commit 747b642 is the furthest we can get without adding the extra visibility.

edited: we could add test/extensions/formatter/metadata/integration_test.cc in the first place, but that would go beyond the scope of this PR since I have to write tests for all metadata types, not only for VIRTUAL_HOST that is added in this PR. I think I would do that in a follow-up PR later. wdyt? @RyanTheOptimist

@RyanTheOptimist
Copy link
Contributor

thank you for clarifying. So I think my last commit 747b642 is the furthest we can get without adding the extra visibility.

edited: we could add test/extensions/formatter/metadata/integration_test.cc in the first place, but that would go beyond the scope of this PR since I have to write tests for all metadata types, not only for VIRTUAL_HOST that is added in this PR. I think I would do that in a follow-up PR later. wdyt? @RyanTheOptimist

Doing this in a follow up would be fine.

@RyanTheOptimist
Copy link
Contributor

/wait
on CI

@mathetake
Copy link
Member Author

/retest

@mathetake
Copy link
Member Author

the verify test failing looks irrelevant to this PR.

@mathetake
Copy link
Member Author

/retest

2 similar comments
@mathetake
Copy link
Member Author

/retest

@mathetake
Copy link
Member Author

/retest

@mathetake
Copy link
Member Author

@phlax verify_examples wasm-cc is constantly failing all over the places recently. Anyone is working on fixing it?

Copy link
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. Some comments are added.

source/extensions/formatter/metadata/metadata.cc Outdated Show resolved Hide resolved
test/extensions/access_loggers/file/BUILD Outdated Show resolved Hide resolved
test/extensions/access_loggers/file/config_test.cc Outdated Show resolved Hide resolved
@wbpcode wbpcode self-assigned this Jul 8, 2024
@wbpcode
Copy link
Member

wbpcode commented Jul 8, 2024

@phlax verify_examples wasm-cc is constantly failing all over the places recently. Anyone is working on fixing it?

This won't block this work anyway.

This reverts commit 747b642.

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@RyanTheOptimist
Copy link
Contributor

@wbpcode friendly ping

@wbpcode wbpcode merged commit 1f79be9 into envoyproxy:main Jul 11, 2024
52 checks passed
@mathetake mathetake deleted the metadatavhost branch July 11, 2024 15:50
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.

None yet

5 participants