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: running skaffold from a directory other than repository root #7430

Merged
merged 1 commit into from
May 20, 2022
Merged

Conversation

morozov
Copy link
Contributor

@morozov morozov commented May 20, 2022

Fixes: #7281
Related: #7251

Description

  1. The bazel cquery command runs in the directory corresponding to the context and returns the tar path relative to that path.
  2. The docker.Push() function is invoked with the same working directory as the current working directory of the process.

Prior to #7251, the path returned by bazel cquery was appended with an absolute path returned by bazel info bazel-bin, so it ended up being an absolute path. With #7251 merged, this no longer happens, so docker.Push() receives a relative path returned by bazel cquery.

If skaffold build is executed in a directory different from the repository root, docker.Push() will receive a relative path against the repository root and won't find the file.

Take the following example. There is a skaffold.yaml file in projects/acme/some-project:

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

This error may be confusing because the path does exist relative to the repository root. It does not exist relative to the current working directory though.

@morozov morozov changed the title Prepend workspace to the TAR path fix: running skaffold from a directory other than repository root May 20, 2022
@codecov
Copy link

codecov bot commented May 20, 2022

Codecov Report

Merging #7430 (ebee661) into main (290280e) will decrease coverage by 3.99%.
The diff coverage is 55.29%.

@@            Coverage Diff             @@
##             main    #7430      +/-   ##
==========================================
- Coverage   70.48%   66.49%   -4.00%     
==========================================
  Files         515      570      +55     
  Lines       23150    27554    +4404     
==========================================
+ Hits        16317    18321    +2004     
- Misses       5776     7903    +2127     
- Partials     1057     1330     +273     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/credits/export.go 0.00% <0.00%> (ø)
cmd/skaffold/app/cmd/deploy.go 50.00% <0.00%> (-3.85%) ⬇️
cmd/skaffold/app/cmd/test.go 44.44% <0.00%> (ø)
cmd/skaffold/skaffold.go 0.00% <0.00%> (ø)
cmd/skaffold/app/cmd/render.go 35.48% <11.11%> (-5.90%) ⬇️
cmd/skaffold/app/cmd/inspect_tests.go 62.50% <14.28%> (-1.14%) ⬇️
cmd/skaffold/app/cmd/lsp.go 28.12% <28.12%> (ø)
cmd/skaffold/app/cmd/fix.go 55.93% <38.88%> (-20.54%) ⬇️
cmd/skaffold/app/cmd/verify.go 41.17% <41.17%> (ø)
cmd/skaffold/app/cmd/lint.go 42.85% <42.85%> (ø)
... and 301 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@morozov morozov marked this pull request as ready for review May 20, 2022 01:45
@morozov morozov requested a review from a team as a code owner May 20, 2022 01:45
@morozov morozov requested a review from renzodavid9 May 20, 2022 01:45
@tejal29 tejal29 added this to the v1.39.0 milestone May 20, 2022
@gsquared94 gsquared94 merged commit 611d000 into GoogleContainerTools:main May 20, 2022
@morozov morozov deleted the issues/7281 branch May 20, 2022 18:41
gsquared94 pushed a commit that referenced this pull request Sep 21, 2022
* fix: running skaffold from a directory other than repository root (#7430)

* use absolute paths to the container_image.tar in bazel build. (#7671)

* fix: use absolute paths to the container_image.tar in bazel build.

* fix unit tests

Co-authored-by: tejal29 <tejal29@gmail.com>

Co-authored-by: Sergei Morozov <morozov@tut.by>
Co-authored-by: Aaron Son <aaron@dolthub.com>
Co-authored-by: tejal29 <tejal29@gmail.com>
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.

Opening image tarball: open bazel-out/darwin../image.tar: no such file or directory
3 participants