Skip to content
This repository has been archived by the owner on Jun 22, 2018. It is now read-only.

Commit

Permalink
Merge pull request #510 from ContainerSolutions/bug/logging-error-han…
Browse files Browse the repository at this point in the history
…dling-image-pulling

Added extra logging and exception handling when pulling images
  • Loading branch information
frankscholten authored Oct 18, 2016
2 parents acad919 + 5516025 commit 885408a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cli/src/main/java/com/containersol/minimesos/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ public int run(String[] args) {

return EXIT_CODE_OK;
} catch (Exception ex) {
output.println("Failed to run command '" + jc.getParsedCommand() + "'. " + ex.getMessage());
if (ex.getMessage() != null) {
output.println("Failed to run command '" + jc.getParsedCommand() + "'. " + ex.getMessage());
} else {
output.println("Failed to run command '" + jc.getParsedCommand() + "'.");
ex.printStackTrace();
}
LOGGER.debug("Exception while processing", ex);
return EXIT_CODE_ERR;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ public void remove() {

protected Boolean imageExists(String imageName, String registryTag) {
List<Image> images = DockerClientFactory.build().listImagesCmd().exec();
if (images.isEmpty()) {
throw new MinimesosException("Failed to find image '" + imageName + ":" + registryTag + ". No images found");
}
for (Image image : images) {
for (String repoTag : image.getRepoTags()) {
if (repoTag.equals(imageName + ":" + registryTag)) {
Expand All @@ -230,6 +233,7 @@ protected Boolean imageExists(String imageName, String registryTag) {
}

protected void pullImage(String imageName, String registryTag) {
LOGGER.debug("Checking if image [" + imageName + ":" + registryTag + "] exists.");

if (imageExists(imageName, registryTag)) {
return;
Expand Down

0 comments on commit 885408a

Please sign in to comment.