-
Notifications
You must be signed in to change notification settings - Fork 691
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
Allows container_pull to postpone image download to build phase. #1749
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: igorgatis The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/assign @smukherj1 |
We have some large images we pull in in our WORKSPACE, and fetching and creating the intermediate forms even when they're not used is a huge performance cost, so this'd be amazing to see added. |
Unfortunately, using the network during an action is considered bad practice and IIRC network access is disabled in many execution contexts, particularly remote execution. We can consult with the core bazel team but I don't think this is going to work as-is.
Also, what are the security implications of this change? Is it possible for an attacker to replace content in an image by deferring download to the build phase? Is hash integrity preserved? @ulfjack any comment here? |
@@ -96,6 +96,10 @@ _container_pull_attrs = { | |||
doc = "(optional) The tag of the image, default to 'latest' " + | |||
"if this and 'digest' remain unspecified.", | |||
), | |||
"lazy_download": attr.bool( | |||
default = False, | |||
doc = "(optional) Indicates whether donwload is postponed to build phase.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spelling
I believe everybody agrees with that. However, the "best practice" makes the scenario of multiple container_pull calls in WORKSPACE impractical. This is why the field lazy_download flag is false by default. User needs to be aware of pros-and-cons. Perhaps, user might make use of this flag only for rarely used images or HUGE images.
We can mitigate this issue passing expected SHA to genrule call. It should be pretty easy to implement. Should I proceed with that? |
https://github.com/bazelbuild/rules_python#fetch-pip-dependencies-lazily-experimental This might be a relevant reference |
Many organizations use an HTTP_CACHE or artifactory to mitigate this. Can you not use that? |
Not every organization has the flexibility to stand something like that up and maintain it. There's still a large startup cost in bigger repos when having to download all images when one or none will be used. I think with sufficient documentation this would be a fantastic feature. |
Perhaps we should discuss at next maintainer meeting. @igorgatis @sluongng @UebelAndre would you be willing to join a call in a few weeks to go over this? |
For sure. Please send and invite to sluongng at gmail dot com. |
What is the conclusion on this? It is a must have for polyglot monorepos and as stated above, has already been implemented in rules_python so there is a precedent for it. I can assess that the patch works perfectly well (thanks @igorgatis btw!) and would really love this to be upstreamed. |
@igorgatis could you fix Buildifier error:
|
message = "Fetching", | ||
outs = ["{outs}"], | ||
cmd = "{args}", | ||
tools = ["{tool}"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tools = ["{tool}"], | |
tools = ["{tool}"], | |
tags = ["requires-network"], |
to make sure network is allowed even in build sandbox
Another interesting thing is compatibility with private registries, for example |
Usage: