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

envoy/api/bazel/api_build_system.bzl requires //docs #3756

Closed
mju opened this issue Jun 29, 2018 · 4 comments
Closed

envoy/api/bazel/api_build_system.bzl requires //docs #3756

mju opened this issue Jun 29, 2018 · 4 comments
Labels
question Questions that are neither investigations, bugs, nor enhancements

Comments

@mju
Copy link
Contributor

mju commented Jun 29, 2018

Title: envoy/api/bazel/api_build_system.bzl requires //docs

Description:
When building an Envoy filter, we needed to use api_proto_library, which tries to grant //docs visibility. See

if visibility == ["//visibility:private"]:
. To us, this is a bug. We are working around by adding a dummy folder and BUILD file or adding visibility = ["//visibility:public"] to the rule. We would like to be able to avoid those hacks.

My guess is that the shell scripts under https://github.com/envoyproxy/envoy/tree/2447cb73ef8f103770dab6b1cb154a3a8f02630e/docs run some bazel commands that need that visibility.

Suggestion I got on how to fix this issue:
"""Get rid of this defaulting behavior in api_proto_library (since it is used in many places external to the envoy_api repo). We could add a wrapper for the API repo that does the defaulting only internally."""

Repro steps:
To reproduce this, try to build https://github.com/envoyproxy/envoy-filter-example/tree/master/http-filter-example as a independent repo.

@mattklein123 mattklein123 added the question Questions that are neither investigations, bugs, nor enhancements label Jun 29, 2018
@mattklein123
Copy link
Member

@htuch @kyessenov @lizan @jmillikin-stripe thoughts here?

@lizan
Copy link
Member

lizan commented Jun 29, 2018

We can modify api_proto_library to sth similar to envoy_cc_* in https://github.com/envoyproxy/envoy/blob/master/bazel/envoy_build_system.bzl, the api_proto_library could take a parameter repository and when it is used outside of envoy, it will grant visibility to repository + "//docs".

@jmillikin-stripe
Copy link
Contributor

This looks like fallout from merging envoy-api/ into envoy/. I'm not familiar with Envoy's proto_library wrappers or docs build, but I can tell the visibility settings make no sense:

  • envoy/docs/ has no BUILD files or targets.
  • envoy/docs/build.sh runs bazel build @envoy_api//docs:protos
  • api_proto_library() is a macro that sets visibility for one target, but also defines C++ and Python proto library targets that appear hard-coded to be //visibility:public.

My recommendation is to remove the //docs bit from api_proto_library().

@htuch
Copy link
Member

htuch commented Jun 29, 2018

@jmillikin-stripe the visibility is for api/docs, we do a trick by which the api/ directory is treated as an external repo, so the path is relative to that. This is done to simplify exporting to the data-plane-api mirror.

I do agree broadly that we should not have api_proto_library contain these api/docs specific workarounds, this is bad. What we should do instead is remove this business logic from api_proto_library and then push this visibility responsibility to the BUILD files (as a BUILD file wide setting) in /api.

mju pushed a commit to mju/envoy that referenced this issue Jun 29, 2018
…ild rule that

adds the required visibility rules and delegates the rest to the generic
api_proto_library.  I tested the change by doing the following without
getting errors.

./ci/run_envoy_docker.sh './ci/do_ci.sh docs'

I changed the BUILD files using the following commands.

/envoy/api$ find . -type f -name BUILD | xargs sed -i -e 's/api_proto_library(/api_proto_library_internal(/g'

envoy/api$ find . -type f -name BUILD | xargs sed -i -e 's/"api_proto_library"/"api_proto_library_internal"/g'

Signed-off-by: mickey <mickeyju@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions that are neither investigations, bugs, nor enhancements
Projects
None yet
Development

No branches or pull requests

5 participants