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;
}
}
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();
}
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();
}
Aggregations