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

Working with a TarImage fails if the tar does not contain explicit directory entries #2067

Closed
Zetten opened this issue Oct 16, 2019 · 5 comments · Fixed by #2068
Closed

Working with a TarImage fails if the tar does not contain explicit directory entries #2067

Zetten opened this issue Oct 16, 2019 · 5 comments · Fixed by #2068
Milestone

Comments

@Zetten
Copy link

Zetten commented Oct 16, 2019

Environment:

  • Jib version: 0.11.0
  • Build tool: jib-core
  • OS: Linux

Description of the issue:
Jib cannot containerize or use as a base an image tar file built by Bazel's rules_docker. Because the tar file does not contain explicit entries for the directory structure (i.e. the file <hash>/VERSION is declared, but not the directory <hash>/), Jib's TarExtractor fails when trying to copy to its temporary extract path any TarEntry files which are in subdirectories.

Expected behavior:
Jib Core is able to unpack and work with layers from a tar built by Bazel.

Steps to reproduce:

  1. Build a docker image tar using Bazel: bazel build :test_image.tar
  2. Try to push the image with Jib.from(TarImage.at(testImage)).containerize(...)

Log output:
Example from a test:

Caused by: java.nio.file.NoSuchFileException: /dev/shm/bazel-sandbox.4e8f4b3b8db28de924ca33f45be42f6d/linux-sandbox/582/execroot/com_cgi_eoss_gaiascope/_tmp/42f1ca17bd58950223768ec9be1efd40/jib-extract-tar4907815467966721691/a815cab1da47c1b1e40f68e08b42c6142de5a555445df26ff05e4be1a2915454/VERSION
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
	at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
	at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
	at java.nio.file.Files.newOutputStream(Files.java:216)
	at com.google.cloud.tools.jib.tar.TarExtractor.extract(TarExtractor.java:61)
	at com.google.cloud.tools.jib.builder.steps.ExtractTarStep.call(ExtractTarStep.java:111)
	at com.google.cloud.tools.jib.builder.steps.StepsRunner.lambda$extractTar$4(StepsRunner.java:253)
	... 6 more

Additional Information:
I have a naive fix locally, which solves the issue: Zetten@426b5a3

@TadCordle
Copy link
Contributor

Hi @Zetten, thanks for pointing this out. I've put up a PR #2068 based on your suggested fix. Would you mind checking out the PR branch i2067-tar-dir-entries and seeing if it fixes your problem?

@chanseokoh
Copy link
Member

@TadCordle if I remember correctly, ExtractTar was designed to work with the tar generated by docker save. Will it continue to work fine after #2068?

@TadCordle
Copy link
Contributor

TadCordle commented Oct 16, 2019

The fix shouldn't change anything for tars that have explicit directory entries, so yes, this will continue to work fine for docker saved tars.

Edit: Integration tests pass with the fix.

@Zetten
Copy link
Author

Zetten commented Oct 16, 2019

Hi @TadCordle, your PR branch works perfectly in my project.

Thanks very much!

@chanseokoh
Copy link
Member

chanseokoh commented Oct 18, 2019

@Zetten we've released jib-core 0.12.0 with this fix.

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

Successfully merging a pull request may close this issue.

3 participants