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

[OCI Load] OCI Load fails if dependents are not pre-built #642

Closed
ankit-agarwal-ai opened this issue Jul 1, 2024 · 6 comments
Closed

[OCI Load] OCI Load fails if dependents are not pre-built #642

ankit-agarwal-ai opened this issue Jul 1, 2024 · 6 comments

Comments

@ankit-agarwal-ai
Copy link
Contributor

Hey all! We are on the beta release of rules_oci and noticed that oci_load sometimes fails if its dependents are not built.

As an example:

BUILD FILE:


tar(
    name = "my_layer",
    testonly = True,
    srcs = [
        ":my_srcs",
    ],
)


oci_image(
    name = "my_image",
    testonly = True,
    base = "@alpine//:alpine",
    tars = [
        ":my_tar",
    ],
    workdir = "/",
)


oci_load(
    name = "my_tarball",
    testonly = True,
    format = "docker",
    image = ":my_image",
    repo_tags = [
        "bazel/tar:latest",
    ],
)

And command

bazel run //tarball:my_tarball 

has the following error when run:

tar: Error reading archive -: Can't open tarball/myimage/blobs/sha256/284f204b5b52127454c9404d7c426126e84c965603635598f0d76278bc767be1
tar: Error exit delayed from previous errors.                                                                                                                                                                                                                                  
open /var/lib/docker/tmp/docker-import-3272200725/blobs/json: no such file or directory

But if I run

bazel build //tarball:my_layer
bazel run //tarball:my_tarball

Then this works correctly.

Looking at the code, my guess is that the oci_load rule doesn't actually have the sha256 blobs in the runfiles of the oci_load rule, so I think those output files would likely need to be propagated up so the load rule can access it.

alexeagle added a commit that referenced this issue Jul 2, 2024
@alexeagle
Copy link
Collaborator

I'm not able to reproduce.

Changes: #644

alex@a:~/Projects/rules_oci/e2e/smoke$ bazel clean --expunge
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
alex@a:~/Projects/rules_oci/e2e/smoke$ bazel run load
Starting local Bazel server and connecting to it...
WARNING: For repository 'bazel_skylib', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph.
WARNING: For repository 'platforms', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph.
INFO: Analyzed target //:load (71 packages loaded, 321 targets configured).
INFO: Found 1 target...
Target //:load up-to-date:
  bazel-bin/load/tarball.spec
INFO: Elapsed time: 2.055s, Critical Path: 0.17s
INFO: 18 processes: 13 internal, 4 linux-sandbox, 1 local.
INFO: Build completed successfully, 18 total actions
INFO: Running command line: bazel-bin/load.sh
Loaded image: my/image:some-tag
Loaded image: my/image:latest

Could you help put up a reproduction?

@alexeagle
Copy link
Collaborator

here is where the inputs to the OCI tarball go into the runfiles of the loader:

runfiles = ctx.runfiles(runtime_deps, transitive_files = tar_inputs)

@ankit-agarwal-ai
Copy link
Contributor Author

Let me try and get a minimal repro from our repo, thanks for the timely response.

@thesayyn
Copy link
Collaborator

thesayyn commented Jul 3, 2024

This probably fixed by #646, @ankit-agarwal1999 can you try with the 2.x branch?

@rohit-giridharan-ai
Copy link

@alexeagle the bazel run works on first attempt, but after a bazel clean is when the error appears. However I can no longer reproduce after switching to commit 4b843d6 - thank you @thesayyn !

@thesayyn
Copy link
Collaborator

thesayyn commented Jul 3, 2024

Great! I am going to close this as fixed.

@thesayyn thesayyn closed this as completed Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants