Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Java image .tar file is not generated in bazel-bin #2014

Closed
juanpmarin opened this issue Feb 4, 2022 · 6 comments
Closed

Java image .tar file is not generated in bazel-bin #2014

juanpmarin opened this issue Feb 4, 2022 · 6 comments

Comments

@juanpmarin
Copy link

juanpmarin commented Feb 4, 2022

🐞 bug report

Affected Rule

java_image

Is this a regression?

Yes, it works well on v0.22.0

Description

I have a java_image target, the label is //src/main/java/com/example/myproject, if I run bazel build //src/main/java/com/example/myproject:myproject.tar it should create a tar file in bazel-bin, which is bazel-out/k8-fastbuild/bin but instead, the tar is generated in the path bazel-out/k8-fastbuild-ST-4a519fd6d3e4/bin

This is the console output

INFO: Analyzed target //src/main/java/com/example/myproject:myproject.tar (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //src/main/java/com/example/myproject:myproject.tar up-to-date:
  bazel-out/k8-fastbuild-ST-4a519fd6d3e4/bin/src/main/java/com/example/myproject/myproject.tar
INFO: Elapsed time: 0.084s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

🔬 Minimal Reproduction

Clone https://github.com/juanpmarin/bazel-java-image-bug
Run bazel build //src/main/java/com/example/myproject:myproject.tar

🌍 Your Environment

Operating System:

  
Fedora 35
  

Output of bazel version:

  
Bazelisk version: v1.11.0
Build label: 5.0.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Jan 19 14:08:54 2022 (1642601334)
Build timestamp: 1642601334
Build timestamp as int: 1642601334
  

Rules_docker version:

  
0.23.0
  

Anything else relevant?

@mashail
Copy link

mashail commented Apr 11, 2022

We have the same issue with go_image

@SanjayVas
Copy link

This also affects the base container_image rule, so I imagine it might affect image tar generation in general.

@SanjayVas
Copy link

I suspect this is an issue with transitions, possibly introduced in #1963

@uhthomas
Copy link
Collaborator

uhthomas commented May 5, 2022

I don't believe bazel-bin is stable, artefacts should be located with cquery instead.

See GoogleContainerTools/skaffold#7251 for an example.

Please feel free to reopen if I'm missing something 😄

@uhthomas uhthomas closed this as completed May 5, 2022
eap added a commit to eap/rules_docker that referenced this issue Jul 6, 2022
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.
gravypod pushed a commit that referenced this issue Jul 7, 2022
* 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!
@njlr
Copy link

njlr commented Jul 25, 2022

For anyone stumbling on this, I was able to get a stable output path by copying the output:

load("@bazel_skylib//rules:copy_file.bzl", "copy_file")

# ...

container_image(
  name = "my_image",
  # ...
)

copy_file(
  name = "my_image_archive",
  src = ":my_image.tar",
  out = "my_image_archive.tar",
  is_executable = False,
  allow_symlink = True,
)

St0rmingBr4in pushed a commit to St0rmingBr4in/rules_docker that referenced this issue Oct 17, 2022
* 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!
@nascentcore-eng
Copy link

For anyone stumbling on this, I was able to get a stable output path by copying the output:

load("@bazel_skylib//rules:copy_file.bzl", "copy_file")

# ...

container_image(
  name = "my_image",
  # ...
)

copy_file(
  name = "my_image_archive",
  src = ":my_image.tar",
  out = "my_image_archive.tar",
  is_executable = False,
  allow_symlink = True,
)

Is this the official way to work around unstable .tar file?
In my case, the .tar file is placed in bazel-out, but the resultant path does not have the actual .tar file.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants