Skip to content

Commit

Permalink
fabric8io#917 additional verbose-level logging whenever we do a POST/…
Browse files Browse the repository at this point in the history
…PUT/DELETE to docker

Signed-off-by: Kenny MacLeod <kmacleod@atlassian.com>
  • Loading branch information
kennymacleod authored and rohanKanojia committed Apr 7, 2019
1 parent 2ff5bd4 commit acaa099
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public void startExecContainer(String containerId, LogOutputSpec outputSpec) thr
request.addProperty("Detach", false);
request.addProperty("Tty", true);

log.verbose("POSTing to %s with %s", url, request);
delegate.post(url, request.toString(), createExecResponseHandler(outputSpec), HTTP_OK);
} catch (Exception e) {
throw new DockerAccessException(e, "Unable to start container id [%s]", containerId);
Expand Down Expand Up @@ -199,6 +200,7 @@ public String createExecContainer(String containerId, Arguments arguments) throw
request.add("Cmd", JsonFactory.newJsonArray(arguments.getExec()));

String execJsonRequest = request.toString();
log.verbose("POSTing to %s with %s", url, execJsonRequest);
try {
String response = delegate.post(url, execJsonRequest, new ApacheHttpClientDelegate.BodyResponseHandler(), HTTP_CREATED);
JsonObject json = JsonFactory.newJsonObject(response);
Expand All @@ -222,6 +224,7 @@ public String createContainer(ContainerCreateConfig containerConfig, String cont

try {
String url = urlBuilder.createContainer(containerName);
log.verbose("POSTing to %s with %s", url, createJson);
String response =
delegate.post(url, createJson, new ApacheHttpClientDelegate.BodyResponseHandler(), HTTP_CREATED);
JsonObject json = JsonFactory.newJsonObject(response);
Expand Down Expand Up @@ -259,6 +262,7 @@ public void stopContainer(String containerId, int killWait) throws DockerAccessE
public void buildImage(String image, File dockerArchive, BuildOptions options) throws DockerAccessException {
try {
String url = urlBuilder.buildImage(image, options);
log.verbose("POSTing to %s with contents of file %s", url, dockerArchive);
delegate.post(url, dockerArchive, createBuildResponseHandler(), HTTP_OK);
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to build image [%s]", image);
Expand All @@ -270,6 +274,7 @@ public void copyArchive(String containerId, File archive, String targetPath)
throws DockerAccessException {
try {
String url = urlBuilder.copyArchive(containerId, targetPath);
log.verbose("PUTing to %s with contents of file %s", url, archive);
delegate.put(url, archive, HTTP_OK);
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to copy archive %s to container [%s] with path %s",
Expand Down Expand Up @@ -391,6 +396,7 @@ public void removeContainer(String containerId, boolean removeVolumes)
throws DockerAccessException {
try {
String url = urlBuilder.removeContainer(containerId, removeVolumes);
log.verbose("DELETEing %s", url);
delegate.delete(url, HTTP_NO_CONTENT);
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to remove container [%s]", containerId);
Expand All @@ -401,6 +407,7 @@ public void removeContainer(String containerId, boolean removeVolumes)
public void loadImage(String image, File tarArchive) throws DockerAccessException {
String url = urlBuilder.loadImage();

log.verbose("POSTing to %s with contents of file %s", url, tarArchive);
try {
delegate.post(url, tarArchive, new BodyAndStatusResponseHandler(), HTTP_OK);
} catch (IOException e) {
Expand Down Expand Up @@ -528,6 +535,7 @@ public String createNetwork(NetworkCreateConfig networkConfig)
log.debug("Network create config: " + createJson);
try {
String url = urlBuilder.createNetwork();
log.verbose("POSTing to %s with %s", url, createJson);
String response =
delegate.post(url, createJson, new ApacheHttpClientDelegate.BodyResponseHandler(), HTTP_CREATED);
log.debug(response);
Expand All @@ -549,6 +557,7 @@ public boolean removeNetwork(String networkId)
throws DockerAccessException {
try {
String url = urlBuilder.removeNetwork(networkId);
log.verbose("DELETEing %s", url);
int status = delegate.delete(url, HTTP_OK, HTTP_NO_CONTENT, HTTP_NOT_FOUND);
return status == HTTP_OK || status == HTTP_NO_CONTENT;
} catch (IOException e) {
Expand All @@ -566,6 +575,7 @@ public String createVolume(VolumeCreateConfig containerConfig)
try
{
String url = urlBuilder.createVolume();
log.verbose("POSTing to %s with %s", url, createJson);
String response =
delegate.post(url,
createJson,
Expand All @@ -587,6 +597,7 @@ public String createVolume(VolumeCreateConfig containerConfig)
public void removeVolume(String name) throws DockerAccessException {
try {
String url = urlBuilder.removeVolume(name);
log.verbose("DELETEing %s", url);
delegate.delete(url, HTTP_NO_CONTENT, HTTP_NOT_FOUND);
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to remove volume [%s]", name);
Expand Down

0 comments on commit acaa099

Please sign in to comment.