Search in sources :

Example 1 with ImagePullFailedException

use of com.spotify.docker.client.exceptions.ImagePullFailedException in project helios by spotify.

the class TaskRunner method pullImage.

private void pullImage(final String image) throws DockerException, InterruptedException {
    listener.pulling();
    DockerTimeoutException wasTimeout = null;
    final Stopwatch pullTime = Stopwatch.createStarted();
    // Attempt to pull.  Failure, while less than ideal, is ok.
    try {
        docker.pull(image);
        listener.pulled();
        log.info("Pulled image {} in {}s", image, pullTime.elapsed(SECONDS));
    } catch (DockerTimeoutException e) {
        log.warn("Pulling image {} failed with timeout after {}s", image, pullTime.elapsed(SECONDS), e);
        listener.pullFailed();
        wasTimeout = e;
    } catch (DockerException e) {
        log.warn("Pulling image {} failed after {}s", image, pullTime.elapsed(SECONDS), e);
        listener.pullFailed();
    }
    try {
        // If we don't have the image by now, fail.
        docker.inspectImage(image);
    } catch (ImageNotFoundException e) {
        // to know, as the pull should have fixed the not found-ness.
        if (wasTimeout != null) {
            throw new ImagePullFailedException("Failed pulling image " + image + " because of timeout", wasTimeout);
        }
        throw e;
    }
}
Also used : DockerException(com.spotify.docker.client.exceptions.DockerException) ImagePullFailedException(com.spotify.docker.client.exceptions.ImagePullFailedException) DockerTimeoutException(com.spotify.docker.client.exceptions.DockerTimeoutException) Stopwatch(com.google.common.base.Stopwatch) ImageNotFoundException(com.spotify.docker.client.exceptions.ImageNotFoundException)

Example 2 with ImagePullFailedException

use of com.spotify.docker.client.exceptions.ImagePullFailedException in project helios by spotify.

the class TaskMonitorTest method verifyMonitorPropagatesImagePullFailed.

@Test
public void verifyMonitorPropagatesImagePullFailed() throws Exception {
    sut.failed(new ImagePullFailedException("foobar", "failure"), "container error");
    verify(statusUpdater).setThrottleState(IMAGE_PULL_FAILED);
    verify(statusUpdater).setState(FAILED);
    verify(statusUpdater).setContainerError("container error");
    verify(statusUpdater).update();
}
Also used : ImagePullFailedException(com.spotify.docker.client.exceptions.ImagePullFailedException) Test(org.junit.Test)

Example 3 with ImagePullFailedException

use of com.spotify.docker.client.exceptions.ImagePullFailedException in project helios by spotify.

the class TaskMonitorTest method verifyImagePullFailureTrumpsFlappingState.

@Test
public void verifyImagePullFailureTrumpsFlappingState() throws Exception {
    when(flapController.isFlapping()).thenReturn(true);
    sut.failed(new ImagePullFailedException("foobar", "failure"), "container error");
    verify(statusUpdater).setThrottleState(IMAGE_PULL_FAILED);
    verify(statusUpdater).setState(FAILED);
    verify(statusUpdater).setContainerError("container error");
    verify(statusUpdater).update();
}
Also used : ImagePullFailedException(com.spotify.docker.client.exceptions.ImagePullFailedException) Test(org.junit.Test)

Aggregations

ImagePullFailedException (com.spotify.docker.client.exceptions.ImagePullFailedException)3 Test (org.junit.Test)2 Stopwatch (com.google.common.base.Stopwatch)1 DockerException (com.spotify.docker.client.exceptions.DockerException)1 DockerTimeoutException (com.spotify.docker.client.exceptions.DockerTimeoutException)1 ImageNotFoundException (com.spotify.docker.client.exceptions.ImageNotFoundException)1