From 402053fa004b38eba08a485e1c6471d2205e60bd Mon Sep 17 00:00:00 2001 From: Xian Chaobo Date: Tue, 7 Jul 2015 17:41:12 +0800 Subject: [PATCH] fix #927 check pull status code Signed-off-by: Xian Chaobo --- Godeps/Godeps.json | 2 +- .../github.com/samalba/dockerclient/dockerclient.go | 12 ++++++++++++ test/integration/api/run.bats | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 13cbf9eb8b..b77ee0ed2a 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -105,7 +105,7 @@ }, { "ImportPath": "github.com/samalba/dockerclient", - "Rev": "a78609286676d55688dcedf8a90522bc7d1bd569" + "Rev": "15ebe064ca62ad0d64834e7ef0d4ed8ce9d02cde" }, { "ImportPath": "github.com/samuel/go-zookeeper/zk", diff --git a/Godeps/_workspace/src/github.com/samalba/dockerclient/dockerclient.go b/Godeps/_workspace/src/github.com/samalba/dockerclient/dockerclient.go index d08d8d1d08..4fb40a33d2 100644 --- a/Godeps/_workspace/src/github.com/samalba/dockerclient/dockerclient.go +++ b/Godeps/_workspace/src/github.com/samalba/dockerclient/dockerclient.go @@ -453,7 +453,19 @@ func (client *DockerClient) PullImage(name string, auth *AuthConfig) error { if err != nil { return err } + defer resp.Body.Close() + if resp.StatusCode == 404 { + return ErrNotFound + } + if resp.StatusCode >= 400 { + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + return err + } + return fmt.Errorf("%s", string(data)) + } + var finalObj map[string]interface{} for decoder := json.NewDecoder(resp.Body); err == nil; err = decoder.Decode(&finalObj) { } diff --git a/test/integration/api/run.bats b/test/integration/api/run.bats index ddcebed6ad..2c07b1486c 100644 --- a/test/integration/api/run.bats +++ b/test/integration/api/run.bats @@ -20,6 +20,10 @@ function teardown() { # verify, container is running [ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ] + + # error check + run docker_swarm run -d 4e8aa3148a132f19ec560952231c4d39522043994df7d2dc239942c0f9424ebd + [[ "${output}" == *"cannot specify 64-byte hexadecimal strings"* ]] } @test "docker run with resources" {