-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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: fix bazel-out path for rules_docker-0.23.0
#7251
fix: fix bazel-out path for rules_docker-0.23.0
#7251
Conversation
rules_docker-0.23.0
rules_docker-0.23.0
rules_docker-0.23.0
rules_docker-0.23.0
hi @sashamor , Thanks for opening this change! It looks like you'll have to go in and update |
Thanks, fixed :) Also changed the arguments to no longer use nested quotes. Tested locally with https://github.com/bazelbuild/rules_docker v0.23.0 and v0.22.0 and can confirm they both find the output tar correctly as expected. |
I wanted to add another data point, I had a similar problem and it worked when running with your patch with multiple images. |
Codecov Report
@@ Coverage Diff @@
## main #7251 +/- ##
==========================================
- Coverage 70.48% 68.50% -1.99%
==========================================
Files 515 560 +45
Lines 23150 26507 +3357
==========================================
+ Hits 16317 18158 +1841
- Misses 5776 7095 +1319
- Partials 1057 1254 +197
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
@sashamor , thanks for making the change! I have a fix open for the github action failure we're seeing Once #7263 is merged, could you rebase this PR to retrigger the tests? I think it should be fixed then |
…/skaffold into sashamor/fix-7228
Thanks for rebasing and merging :) Woohoo |
…ls#7251) Co-authored-by: Marlon Gamez <marlongamez98@gmail.com>
} | ||
|
||
tarPath := filepath.Join(bazelBin, buildTarPath(a.BuildTarget)) |
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.
It looks like this breaks the scenarios where the artifact has a non-default context and the skaffold
command is executed from within a path different than the repository root.
The bazel cquery
runs in the directory corresponding to the context and returns the tar path relative to that context but docker.Push()
still runs in the current working directory and is now supplied with a path relative to the context, not relative to the current working directory.
Take the following example. There is a skaffold file in projects/acme/some-projects:
apiVersion: skaffold/v2beta26
kind: Config
build:
artifacts:
- image: quay.io/acme/some-project
context: ../../..
If one does:
cd projects/acme/some-projects && skaffold build
It will no longer work. It will fail with an error like:
build [quay.io/acme/some-project] failed: reading image "bazel-out/darwin-fastbuild-ST-4a519fd6d3e4/bin/projects/some-project/docker.tar": open bazel-out/darwin-fastbuild-ST-4a519fd6d3e4/bin/projects/some-project//docker.tar: no such file or directory
I guess this is the same issue as reported in #7281.
Summary: This includes the fixes from GoogleContainerTools/skaffold#7251 which makes skaffold work with the new version of rules_docker and the output locations of built images. Test Plan: Deployed a dev vizier with skaffold Reviewers: michelle, zasgar Reviewed By: zasgar Signed-off-by: Vihang Mehta <vihang@pixielabs.ai> Differential Revision: https://phab.corp.pixielabs.ai/D11550 GitOrigin-RevId: fb39f7a
The tar output location has been changed and is no longer stable. The old docs were not updated at the time of the change and the result is confusing build breakages. Until the original behavior is added back (not clear that it will happen) the README should document the new behavior. See Issue bazelbuild#2014 for more info (this was closed as WAI), and [GoogleContainerTools PR#7251](GoogleContainerTools/skaffold#7251) for more context.
* Update README to account for new tar build output The tar output location has been changed and is no longer stable. The old docs were not updated at the time of the change and the result is confusing build breakages. Until the original behavior is added back (not clear that it will happen) the README should document the new behavior. See Issue #2014 for more info (this was closed as WAI), and [GoogleContainerTools PR#7251](GoogleContainerTools/skaffold#7251) for more context. * Update README.md add ".tar" to the query, it is needed!
Summary: This includes the fixes from GoogleContainerTools/skaffold#7251 which makes skaffold work with the new version of rules_docker and the output locations of built images. Test Plan: Deployed a dev vizier with skaffold Reviewers: michelle, zasgar Reviewed By: zasgar Signed-off-by: Vihang Mehta <vihang@pixielabs.ai> Differential Revision: https://phab.corp.pixielabs.ai/D11550 GitOrigin-RevId: fb39f7a
Summary: This includes the fixes from GoogleContainerTools/skaffold#7251 which makes skaffold work with the new version of rules_docker and the output locations of built images. Test Plan: Deployed a dev vizier with skaffold Reviewers: michelle, zasgar Reviewed By: zasgar Signed-off-by: Vihang Mehta <vihang@pixielabs.ai> Differential Revision: https://phab.corp.pixielabs.ai/D11550 GitOrigin-RevId: fb39f7a
Summary: This includes the fixes from GoogleContainerTools/skaffold#7251 which makes skaffold work with the new version of rules_docker and the output locations of built images. Test Plan: Deployed a dev vizier with skaffold Reviewers: michelle, zasgar Reviewed By: zasgar Signed-off-by: Vihang Mehta <vihang@pixielabs.ai> Differential Revision: https://phab.corp.pixielabs.ai/D11550 GitOrigin-RevId: fb39f7a
* Update README to account for new tar build output The tar output location has been changed and is no longer stable. The old docs were not updated at the time of the change and the result is confusing build breakages. Until the original behavior is added back (not clear that it will happen) the README should document the new behavior. See Issue bazelbuild#2014 for more info (this was closed as WAI), and [GoogleContainerTools PR#7251](GoogleContainerTools/skaffold#7251) for more context. * Update README.md add ".tar" to the query, it is needed!
…ls#7251) Co-authored-by: Marlon Gamez <marlongamez98@gmail.com>
Fixes: #7228
Related: bazelbuild/rules_docker#1963
Merge before/after: Dependent or prerequisite PRs
Description
With the release of https://github.com/bazelbuild/rules_docker/releases/tag/v0.23.0, the output directory for bazel targets is calculated differently and is no longer a static path.
For example, a
container_image
target such as:Previously was stored at:
Internally,
skaffold
calculated this path by runningbazel info bazel-bin
, which returns the start of the path (e.g./home/...../execroot/__main__/bazel-out/k8-fastbuild/bin
), then appended the name of the rule with:
replaced with/
(e.g.foo/bar/server/server_img.tar
). This results in the correct path as above.However, with
rules_docker-0.23.0
, the output is now stored at a path like:So
bazel info
no longer returns the correct path prefix.Using
bazel cquery
with a similar method to that described in https://github.com/bazelbuild/rules_pkg/tree/main/examples/where_is_my_output, as recommended in bazelbuild/rules_docker#1963 (comment), we can query Bazel for the actual output path to the target. Docker.tar
output files are available incquery
as targets with a.files
attribute, which contains the list of output files (there's only one), and each file has a.path
attribute that gives the path to the file, which we can use internally in Skaffold. This is also backwards compatible with older versions of https://github.com/bazelbuild/rules_docker.For example, the command:
May return:
And with
rules_docker-0.23.0
, this may return something like:Which is the correct path to the target.