Skip to content

Commit

Permalink
Merge pull request #725 from thoschaefer/fix/improve_temporary_tag_re…
Browse files Browse the repository at this point in the history
…moval

PR merged! Thanks!
  • Loading branch information
fusesource-ci authored Mar 20, 2017
2 parents 2d23669 + e5ee4d8 commit b68a36a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
- Improve resource management for certificates and keys. (#730)
- When using properties for configuration only build when `from` or `fromExt` is set (#736)
- Add new mojo "docker:save" for saving the image to a file (#687)

- Check whether a temporary tag could be removed and throw an error if not (#725)

* **0.20.0** (2017-02-17)
- Removed `build-nofork` and `source-nofork` in favor for a more direct solution which prevents forking of the lifecycle. Please refer the documentation, chapter "Assembly" for more information about this.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.*;
import java.net.URI;
import java.util.*;
import java.util.zip.GZIPOutputStream;

import io.fabric8.maven.docker.access.*;
import io.fabric8.maven.docker.access.chunked.BuildJsonResponseHandler;
Expand All @@ -28,7 +27,6 @@
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.codehaus.plexus.archiver.commonscompress.compressors.bzip2.BZip2CompressorOutputStream;
import org.json.JSONArray;
import org.json.JSONObject;

Expand Down Expand Up @@ -367,13 +365,21 @@ public void pushImage(String image, AuthConfig authConfig, String registry, int
ImageName name = new ImageName(image);
String pushUrl = urlBuilder.pushImage(name, registry);
String temporaryImage = tagTemporaryImage(name, registry);
DockerAccessException dae = null;
try {
doPushImage(pushUrl, createAuthHeader(authConfig), createPullOrPushResponseHandler(), HTTP_OK, retries);
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to push '%s'%s", image, (registry != null) ? " from registry '" + registry + "'" : "");
dae = new DockerAccessException(e, "Unable to push '%s'%s", image, (registry != null) ? " from registry '" + registry + "'" : "");
throw dae;
} finally {
if (temporaryImage != null) {
removeImage(temporaryImage);
if (!removeImage(temporaryImage, true)) {
if (dae == null) {
throw new DockerAccessException("Image %s could be pushed, but the temporary tag could not be removed", temporaryImage);
} else {
throw new DockerAccessException(dae.getCause(), dae.getMessage() + " and also temporary tag [%s] could not be removed, too.", temporaryImage);
}
}
}
}
}
Expand Down

0 comments on commit b68a36a

Please sign in to comment.