FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Implementation of POST /images/load endpoint by leonsabr · Pull Request #627 · docker-java/docker-java · GitHub

Repository navigation

Implementation of POST /images/load endpoint - #627

Merged
KostyaSha merged 1 commit into
docker-java:masterfrom
leonsabr:images_load
Jul 14, 2016
Merged

KostyaSha merged 1 commit into
docker-java:masterfrom
leonsabr:images_load

Conversation

leonsabr commented Jul 6, 2016 •
edited by marcuslinke
Loading

Copy link
Copy Markdown
Contributor

This is an implementation of POST /images/load endpoint.

A few words about testing. I added a small tarball (20 kB) with a single image named "docker-java/load:1.0". Tests try to load this tarball into docker, check if expected image appears, and remove it in @AfterMethod. Test for netty implementation is the same as for jaxrs/jersey implementation.


This change is

Copy link
Copy Markdown
Member

About tar, maybe create it with text instructions in container and then copy from container (command already exists)?


final Image image = findImageWithId(expectedImageId, dockerClient.listImagesCmd().exec());

assertNotNull(image, "Can't find expected image after loading from a tar archive");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

please use hamcrest matchers

Copy link
Copy Markdown
Member

in general lgtm beside comments

KostyaSha commented Jul 6, 2016 •
edited
Loading

Copy link
Copy Markdown
Member

Or even you can generate tar with apache.io tar, should be not so much lines of code!

leonsabr commented Jul 6, 2016

Copy link
Copy Markdown
Contributor Author

About tar, maybe create it with text instructions in container and then copy from container (command already exists)?

Please, give me more details. This image tarball should have a strict format.

Copy link
Copy Markdown
Member

Sorry, right name of library https://commons.apache.org/proper/commons-compress/tar.html that would work for creating tar.

Not sure about The layer.tar file contains aufs style .wh..wh.aufs files and directories for storing attribute changes and deletions. How you created it now?

Copy link
Copy Markdown
Member

And one more idea, could you check how docker tests this case? https://github.com/docker/docker/search?utf8=%E2%9C%93&q=layer.tar
I usually picking their tests into docker-java.
PS. if there is no way to create tar programmatically than it would be ok to keep it as binary in repo.


@Test
public void loadImageFromTar() throws Exception {
final Path imageTarFile = Paths.get("src/test/resources/testLoadImageFromTar/image.tar");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

please use CurrentThread classloader to get input stream - as of on different os this path may be changed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That load from relative path, it related to maven plugin that executes it from root of project. So classloaders unrelated. Ideally you should put test resources under class_name/test_name and then load from classloader this test resource.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please give me an example of under class_name/test_name rule? It looks like directories in src/test/resources/ violates this rule. Should I use src/test/resources/LoadImageCmdImplTest/loadImageFromTar/image.tar? What if one resource is used by several classes?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Then you can make public getter but place it in one place. The issue with placing just in resources that it will be like a trash can and after test deletions/refactorings they will be forgotten.
@leonsabr will search for examples bit later.

leonsabr commented Jul 6, 2016

Copy link
Copy Markdown
Contributor Author

In order to get this tarball I manually did the following:

  1. Created a simple Dockerfile which produces a 2-layer image.
  2. docker build -t docker-java/load:1.0 .
  3. docker save docker-java/load:1.0 > image.tar

As I see, Docker guys have tarballs in repository:

$ find docker -type f -name "*.tar"
docker/integration-cli/fixtures/load/emptyLayer.tar
docker/pkg/archive/testdata/broken.tar
docker/pkg/tarsum/testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar
docker/pkg/tarsum/testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/layer.tar
docker/pkg/tarsum/testdata/collision/collision-0.tar
docker/pkg/tarsum/testdata/collision/collision-1.tar
docker/pkg/tarsum/testdata/collision/collision-2.tar
docker/pkg/tarsum/testdata/collision/collision-3.tar
docker/pkg/tarsum/testdata/xattr/layer.tar

As I understand you suggest to have text files in resources, then in runtime create a tarball according to format? It is tricky because tarball contains layer tarballs inside. So you need to create correct layer tarballs, then put them in the image tarball.

By the way, I can do a smaller tarball, with one layer, a few kB.

Copy link
Copy Markdown
Member

Or we can pick some their tarball..

Copy link
Copy Markdown
Member

So ok to have tarball in repo. But please place under corresponding class name

leonsabr commented Jul 6, 2016

Copy link
Copy Markdown
Contributor Author

What was changed in second commit:

  1. Hamcrest matchers
  2. Smaller tarball 12 kB
  3. TestResources class which provides access to the tarball's Path. Tarball is placed in resources/api/images/load/image.tar directory. What do you think about such approach?

I will squash commits for cleaner history later.


CreateImageCmd createImageCmd(@Nonnull String repository, @Nonnull InputStream imageStream);

LoadImageCmd loadImageCmd(@Nonnull InputStream imageStream);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

When this feature appeared in docker API? Could you place javadoc with since (example could be found through search) ?

Copy link
Copy Markdown
Member

LGTM, javadoc with API version would be welcome.

Copy link
Copy Markdown
Contributor Author

It was tricky but I found the first reference of this endpoint in docs/reference/api/docker_remote_api_v1.7.md. Now this docs are removed from the Docker website.

I squashed commits, so now all changes are in a single commit.

Copy link
Copy Markdown
Member

@leonsabr thanks! it was enough to check latest 3-4 api versions and mark with latest known. I don't think that anybody using 1.8 :)

KostyaSha merged commit d803c46 into docker-java:master Jul 14, 2016
KostyaSha added this to the 3.0.1 milestone Jul 14, 2016
leonsabr deleted the images_load branch July 15, 2016 09:50

KostyaSha commented Aug 14, 2016 •
edited
Loading

Copy link
Copy Markdown
Member

@leonsabr 1.12 build fails with

Tests run: 323, Failures: 1, Errors: 0, Skipped: 2, Time elapsed: 556.507 sec <<< FAILURE! - in TestSuite
(com.github.dockerjava.netty.exec.LoadImageCmdExecTest)  Time elapsed: 0.152 sec  <<< FAILURE!
io.netty.handler.codec.CorruptedFrameException: invalid JSON received at byte position 0: 4c6f6164656420696d6167653a20646f636b65722d6a6176612f6c6f61643a312e300a
Results :
Failed tests: 
  LoadImageCmdExecTest.loadImageFromTar » CorruptedFrame invalid JSON received a...

Plus i found that it has verbose output #664


/**
* Online documentation is not available anymore.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

sinde docker 1.7 or 1.7 API?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

found

panuse pushed a commit to TuKangTech/docker-java that referenced this pull request Aug 20, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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 this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL