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

tooling: Use envoy_entry_point #19536

Merged
merged 3 commits into from
Jan 19, 2022
Merged

Conversation

phlax
Copy link
Member

@phlax phlax commented Jan 13, 2022

Signed-off-by: Ryan Northey ryan@synca.io

Commit Message:

This is a follow up to use the macro added in #19450 for existing entry_points

Also contains a fix to use a template to create the py_binary main to ensure the py_binary retains the path to the entry point

Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

@phlax phlax force-pushed the tooling-entry-points branch 2 times, most recently from b1411fd to 857f43f Compare January 13, 2022 17:24
@phlax phlax changed the title tooling: Use envoy_entry_point [WIP] tooling: Use envoy_entry_point Jan 13, 2022
@phlax phlax marked this pull request as draft January 13, 2022 17:53
@phlax phlax force-pushed the tooling-entry-points branch 5 times, most recently from 3962070 to 1050fbf Compare January 17, 2022 08:30
Signed-off-by: Ryan Northey <ryan@synca.io>
@phlax phlax force-pushed the tooling-entry-points branch from 1050fbf to d6beb75 Compare January 17, 2022 08:52
@phlax phlax changed the title [WIP] tooling: Use envoy_entry_point tooling: Use envoy_entry_point Jan 17, 2022
@phlax phlax marked this pull request as ready for review January 17, 2022 08:53
def find_tool_path():
entry_point_alias = ENTRY_POINT_ALIAS.split("/external/")[1]

for x in pathlib.Path(".").glob(f"**/{entry_point_alias}"):
Copy link
Member

Choose a reason for hiding this comment

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

This seems a bit of a wide net to cast. PR LGTM otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

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

the entry point alias that its matching is a pretty long string - if it matches we can be fairly sure we found the binary

i couldnt find any other way to do it - not sure why but the location im getting back from the alias wasnt matching exactly, even tho the tool is actually there (on a slightly different filepath)

Copy link
Member

Choose a reason for hiding this comment

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

Can you provide some concrete path examples? I think it's probably OK as a workaround, but it just has a code smell to it, where we might end up with some hard to diagnose bug later due to this use of globbing.

Copy link
Member Author

Choose a reason for hiding this comment

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

it just has a code smell to it

yep, agreed, i spent quite a few hours on this, and didnt find an alternative - so reluctantly did it this way - ill dump what is being mangled now and add as a comment...

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm, not sure about adding a comment as the lines are very long, ill post here for now and we can figure out

essentially there are 2 situations that it needs to work in - when its called directly with bazel run //path/to:entry_point and where are a build rule calls it - ie bazel build //rule/that/calls:entry_point

This is the before/after mangling for the first - ie bazel run

ENTRY_POINT_ALIAS: bazel-out/k8-opt-exec-2B5CBBC6/bin/external/base_pip3_envoy_docs_sphinx_runner/rules_python_wheel_entry_point_envoy.docs.sphinx_runner
FOUND PATH: external/base_pip3_envoy_docs_sphinx_runner/rules_python_wheel_entry_point_envoy.docs.sphinx_runner

And this is for the second:

ENTRY_POINT_ALIAS: bazel-out/host/bin/external/base_pip3_envoy_docs_sphinx_runner/rules_python_wheel_entry_point_envoy.docs.sphinx_runner
FOUND PATH: bazel-out/host/bin/tools/docs/sphinx_runner.runfiles/base_pip3_envoy_docs_sphinx_runner/rules_python_wheel_entry_point_envoy.docs.sphinx_runner

Copy link
Member Author

Choose a reason for hiding this comment

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

ive cleaned the macro up a little, but whatever way i look at it the path that the genrule sees is different from the path that the py_binary sees

im pretty confident that this workaround works, not sure how else to achieve the desired outcome

Copy link
Member

Choose a reason for hiding this comment

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

OK. The only other suggestions I would have here are to think of (1) passing the path in via command-line from Bazel which should know what it is or (2) using Bazel query. @lizan might also have some insight. In any case, it's probably not worth spending a ton of time optimizing, so maybe just document why this is the way it is and we can land.

Copy link
Member Author

Choose a reason for hiding this comment

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

passing via the path wont work - its the reason for shifting to using a template - the arg gets lost when the rule is called from another rule, ill add a comment now...

@phlax phlax force-pushed the tooling-entry-points branch from 56a76a6 to 8ec1c68 Compare January 17, 2022 18:57
Signed-off-by: Ryan Northey <ryan@synca.io>
@phlax phlax force-pushed the tooling-entry-points branch from 8ec1c68 to e1ed46b Compare January 17, 2022 19:37
Signed-off-by: Ryan Northey <ryan@synca.io>
Copy link
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.

Ack, thanks, I'm going to chalk this one up to another Bazel workaround, which we have plenty of, thanks.

@htuch htuch merged commit f7b1dc6 into envoyproxy:main Jan 19, 2022
joshperry pushed a commit to joshperry/envoy that referenced this pull request Feb 13, 2022
This is a follow up to use the macro added in envoyproxy#19450 for existing entry_points

Also contains a fix to use a template to create the py_binary main to ensure the py_binary retains the path to the entry point

Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Josh Perry <josh.perry@mx.com>
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.

2 participants