From 5096c18be2feb64e49a0e478e620ce72128b4c12 Mon Sep 17 00:00:00 2001 From: CMGS Date: Tue, 25 Jul 2017 13:30:03 +0800 Subject: [PATCH] Revert "compatible with new docker api" This reverts commit f74fff92a5c1f9cb09e0f3ac315d980193926a05. --- Makefile | 4 ---- cluster/calcium/run_and_wait.go | 13 +++---------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 37f6f53c3..5b3267864 100644 --- a/Makefile +++ b/Makefile @@ -33,11 +33,7 @@ deps: go get -u -v -d github.com/coreos/etcd go get -u -v -d github.com/docker/docker/api/types || echo oops go get -u -v -d github.com/docker/docker/api/types/container - go get -u -v -d golang.org/x/sys/unix - go get -u -v -d github.com/opencontainers/image-spec/specs-go/v1 - go get -u -v -d github.com/opencontainers/go-digest rm -rf $GOPATH/src/github.com/docker/docker/vendor - rm -rf $GOPATH/src/github.com/docker/distribution/vendor build: go build -ldflags "$(GO_LDFLAGS)" -a -tags netgo -installsuffix netgo -o eru-core diff --git a/cluster/calcium/run_and_wait.go b/cluster/calcium/run_and_wait.go index 1530d510f..263e1e9db 100644 --- a/cluster/calcium/run_and_wait.go +++ b/cluster/calcium/run_and_wait.go @@ -9,7 +9,6 @@ import ( log "github.com/Sirupsen/logrus" enginetypes "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/container" "gitlab.ricebook.net/platform/core/types" "gitlab.ricebook.net/platform/core/utils" "golang.org/x/net/context" @@ -123,17 +122,11 @@ func (c *calcium) RunAndWait(specs types.Specs, opts *types.DeployOptions, stdin // 超时的情况下根本不会到这里 // 不超时的情况下这里肯定会立即返回 - statusBodyChan, errChan := node.Engine.ContainerWait( - context.Background(), containerID, container.WaitConditionNotRunning) - - var exitData []byte - select { - case err := <-errChan: + code, err := node.Engine.ContainerWait(context.Background(), containerID) + exitData := []byte(fmt.Sprintf("[exitcode] %d", code)) + if err != nil { log.Errorf("[RunAndWait] %s run failed, %v", containerID[:12], err) exitData = []byte(fmt.Sprintf("[exitcode] unknown %v", err)) - case statusBody := <-statusBodyChan: - code := statusBody.StatusCode - exitData = []byte(fmt.Sprintf("[exitcode] %d", code)) } ch <- &types.RunAndWaitMessage{ContainerID: containerID, Data: exitData} }(node, message.ContainerID)