From d53aaff9307ae4b03ffd041bbad8ebd64801f098 Mon Sep 17 00:00:00 2001 From: Yunhee Date: Mon, 24 Dec 2018 16:31:10 -0800 Subject: [PATCH] flushing load image response before returning success --- agent/dockerclient/dockerapi/docker_client.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/agent/dockerclient/dockerapi/docker_client.go b/agent/dockerclient/dockerapi/docker_client.go index 06a4c5449e9..e46a14b483f 100644 --- a/agent/dockerclient/dockerapi/docker_client.go +++ b/agent/dockerclient/dockerapi/docker_client.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "io" + "io/ioutil" "math/rand" "strconv" "strings" @@ -946,8 +947,8 @@ func (dg *dockerGoClient) handleContainerEvents(ctx context.Context, metadata := dg.containerMetadata(ctx, containerID) changedContainers <- DockerContainerChangeEvent{ - Status: status, - Type: eventType, + Status: status, + Type: eventType, DockerContainerMetadata: metadata, } } @@ -1383,6 +1384,14 @@ func (dg *dockerGoClient) loadImage(ctx context.Context, reader io.Reader) error if err != nil { return err } - _, err = client.ImageLoad(ctx, reader, false) + resp, err := client.ImageLoad(ctx, reader, false) + if err != nil { + return err + } + + // flushing response reader + if resp.Body != nil { + _, err = io.Copy(ioutil.Discard, resp.Body) + } return err }