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

improved logging when unable to fetch docker image #2443

Closed
dbyron0 opened this issue Mar 16, 2020 · 2 comments
Closed

improved logging when unable to fetch docker image #2443

dbyron0 opened this issue Mar 16, 2020 · 2 comments

Comments

@dbyron0
Copy link
Contributor

dbyron0 commented Mar 16, 2020

From https://testcontainers.slack.com/archives/C1SUBPZK6/p1584131893103200:

I’m trying to debug a struggle with pulling a docker image in a CI environment. At the moment, I see this:

[21:30:36][docker]         Caused by:
[21:30:36][docker]         org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageNameFuture=java.util.concurrent.CompletableFuture@55d9985c[Completed normally], imagePullPolicy=DefaultPullPolicy(), dockerClient=LazyDockerClient.INSTANCE)
[21:30:36][docker]             at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1265)
[21:30:36][docker]             at org.testcontainers.containers.GenericContainer.logger(GenericContainer.java:600)
[21:30:36][docker]             at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:311)
[21:30:36][docker]             ... 2 more
[21:30:36][docker] 
[21:30:36][docker]             Caused by:
[21:30:36][docker]             com.github.dockerjava.api.exception.InternalServerErrorException: {"message":"Get https://quay.io/v2/: Forbidden"}

but no where in there do I actually get to see the name of the image that’s failing. The relevant code (from https://github.com/testcontainers/testcontainers-java/blob/master/core/src/main/java/org/testcontainers/containers/GenericContainer.java#L1265) is:

        try {
            return image.get();
        } catch (Exception e) {
            throw new ContainerFetchException("Can't get Docker image: " + image, e);
        }

Any thoughts on how to improve it to see the image name?

@bsideup
Copy link
Member

bsideup commented Mar 17, 2020

Hi @dbyron0,

I marked it as "good first issue". One way of implementing it would be to improve RemoteDockerImage and/or imageNameFuture, so that it is included in the output.

dbyron0 pushed a commit to locationlabs/testcontainers-java that referenced this issue Mar 17, 2020
@dbyron0
Copy link
Contributor Author

dbyron0 commented Mar 17, 2020

Like this ?

dbyron0 pushed a commit to locationlabs/testcontainers-java that referenced this issue Mar 17, 2020
@testcontainers testcontainers deleted a comment from jhonathan-007 Mar 19, 2020
quincy pushed a commit to quincy/testcontainers-java that referenced this issue May 28, 2020
* clean up imports in GenericContainer

* include image name in RemoteDockerImage.toString() to fix testcontainers#2443

* test RemoteDockerImage directly

* handle failures getting the image name

* use completeExceptionally instead of mocking

* tweak assertions

* more assertion tweaks

* add isDone check to RemoteDockerImage.toString -- still figuring out why test fails

* go back to using lombok @tostring, exclude dockerClient while we're at it

* use `Futures.lazyTransform` that also proxies `isDone`

* `imageNameToString` should not be public

* Include the message on error

Co-authored-by: Byron David <david.byron@avast.com>
Co-authored-by: David Byron <dbyron@dbyron.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants