Failed quickly if docker image not found

This commit is contained in:
Girish Ramakrishnan
2020-03-06 16:39:20 -08:00
parent 65f573b773
commit 7a63fd4711

View File

@@ -143,6 +143,7 @@ function pullImage(manifest, callback) {
debug(`pullImage: will pull ${manifest.dockerImage}. auth: ${authConfig ? 'yes' : 'no'}`);
gConnection.pull(manifest.dockerImage, { authconfig: authConfig }, function (error, stream) {
if (error && error.statusCode === 404) return callback(new BoxError(BoxError.NOT_FOUND, `Unable to pull image ${manifest.dockerImage}. message: ${error.message} statusCode: ${error.statusCode}`));
if (error) return callback(new BoxError(BoxError.DOCKER_ERROR, `Unable to pull image ${manifest.dockerImage}. Please check the network or if the image needs authentication. statusCode: ${error.statusCode}`));
// https://github.com/dotcloud/docker/issues/1074 says each status message
@@ -180,14 +181,10 @@ function downloadImage(manifest, callback) {
var attempt = 1;
async.retry({ times: 10, interval: 15000 }, function (retryCallback) {
async.retry({ times: 10, interval: 5000, errorFilter: e => e.reason !== BoxError.NOT_FOUND }, function (retryCallback) {
debug('Downloading image %s. attempt: %s', manifest.dockerImage, attempt++);
pullImage(manifest, function (error) {
if (error) console.error(error);
retryCallback(error);
});
pullImage(manifest, retryCallback);
}, callback);
}