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

Fix workdir and expand arg location. #452

Merged
merged 9 commits into from
Jul 17, 2018

Conversation

Globegitter
Copy link
Contributor

This supersedes #365. And should fix #355, #378, #451

@Globegitter Globegitter changed the title Fix workdir, bazel run arg duplication and expand arg location. Fix workdir and expand arg location. Jul 11, 2018
@nlopezgi
Copy link
Contributor

Thanks a lot for sending this PR! Looks good overall, will review in more detail in a bit, kicked off presubmits to make sure everything is passing.

Copy link
Contributor

@nlopezgi nlopezgi left a comment

Choose a reason for hiding this comment

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

thanks again, some minor nits, but this looks good to submit once addressed.

@@ -74,6 +74,8 @@ def py3_image(name, base = None, deps = [], layers = [], **kwargs):
# TODO(mattmoor): Consider using par_binary instead, so that
# a single target can be used for all three.

args = kwargs.pop("args", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this necessary for py3 image but not for others?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry this is still a leftover, I also tried to fix the issue that args are being passed in twice.

@@ -19,6 +21,9 @@ def main():
print('Second: %d' % py3_image_library.fn(2))
print('Third: %d' % py3_image_library.fn(3))
print('Fourth: %d' % py3_image_library.fn(4))
print(sys.argv)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add short doc line somewhere indicating these two tests (py3, py) expect the third argument to be a file location

lang/image.bzl Outdated
"directory": attr.string(default = "/app"),
"legacy_run_behavior": attr.bool(default = False),
"data": attr.label_list(cfg = "data", allow_files = True),
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have seen some doc referring that for data it should still be data, there is also a ticket for it: bazelbuild/bazel#4316. But here: https://github.com/bazelbuild/examples/blob/5d1e5bd82e061e8e2e04bb54883fc4c79c935f76/rules/runfiles/execute.bzl#L32 there is nothing, so I will just remove it.

lang/image.bzl Outdated
})

args = [ctx.expand_location(arg, ctx.attr.data) for arg in ctx.attr.args]
Copy link
Contributor

Choose a reason for hiding this comment

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

add doc comment above explaining you are expanding locations of the form $(location :some_target)

java/image.bzl Outdated
"legacy_run_behavior": attr.bool(default = False),
"data": attr.label_list(cfg = "data", allow_files = True),
Copy link
Contributor

Choose a reason for hiding this comment

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

java/image.bzl Outdated
@@ -166,12 +168,13 @@ def _jar_app_layer_impl(ctx):

binary_path = layer_file_path(ctx, ctx.files.binary[0])
classpath_path = layer_file_path(ctx, classpath_file)
args = [ctx.expand_location(arg, ctx.attr.data) for arg in ctx.attr.args]
Copy link
Contributor

Choose a reason for hiding this comment

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

add doc comment about expanding location

@@ -158,6 +158,8 @@ def incremental_load(
),
]
if run:
# bazel automatically passes ctx.attr.args to the binary on run, so need to truncate
# them here to not pass twice, as they are already part of the docker entrypoint
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a pointer to the Bazel issue you opened so we can track and remove once that is fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also still a leftover from when I tried to also fix that issue. Yes will clean up.

@nlopezgi nlopezgi merged commit f5ed963 into bazelbuild:master Jul 17, 2018
@Globegitter Globegitter deleted the workdir-fix branch July 17, 2018 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nodejs_image does not preserve data filepaths
3 participants