Skip to content

Commit

Permalink
Upgrade Docker client version
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Jul 24, 2018
1 parent 1d0a2b9 commit 0b27811
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 28 deletions.
43 changes: 34 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
name = "github.com/sirupsen/logrus"
version = "1.0.5"

[[constraint]]
name = "github.com/docker/docker"
version = "v17.03.2-ce"

[[constraint]]
name = "github.com/dgrijalva/jwt-go"
version = "3.2.0"
Expand All @@ -38,3 +34,15 @@
[[constraint]]
name = "github.com/aws/aws-sdk-go"
version = "1.14.10"

[[constraint]]
name = "github.com/docker/docker"
branch = "master"

[[override]]
name = "github.com/docker/distribution"
branch = "master"

[[override]]
name = "github.com/docker/libnetwork"
revision = "19279f0492417475b6bfbd0aa529f73e8f178fb5"
42 changes: 28 additions & 14 deletions daemon/inertiad/build/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,22 @@ func (b *Builder) dockerCompose(d *Config, cli *docker.Client,
}
stop := make(chan struct{})
go containers.StreamContainerLogs(cli, resp.ID, out, stop)
status, err := cli.ContainerWait(ctx, resp.ID)
close(stop)
if err != nil {
return nil, err
statusCh, errCh := cli.ContainerWait(ctx, resp.ID, "")
var status container.ContainerWaitOKBody
select {
case err := <-errCh:
if err != nil {
return nil, err
}
case status = <-statusCh:
// Exit log stream
close(stop)
}
if status != 0 {
return nil, errors.New("Build exited with non-zero status: " + strconv.FormatInt(status, 10))
if status.StatusCode != 0 {
return nil, fmt.Errorf(
"Build exited with non-zero status %s", strconv.FormatInt(status.StatusCode, 10))
}
fmt.Fprintln(out, "Build exited with status "+strconv.FormatInt(status, 10))
fmt.Fprintln(out, "Build exited with status "+strconv.FormatInt(status.StatusCode, 10))

// @TODO allow configuration
dockerComposeRelFilePath := "docker-compose.yml"
Expand Down Expand Up @@ -317,15 +324,22 @@ func (b *Builder) herokuishBuild(d *Config, cli *docker.Client,
// Attach logs and report build progress until container exits
stop := make(chan struct{})
go containers.StreamContainerLogs(cli, resp.ID, out, stop)
status, err := cli.ContainerWait(ctx, resp.ID)
close(stop)
if err != nil {
return nil, err
statusCh, errCh := cli.ContainerWait(ctx, resp.ID, "")
var status container.ContainerWaitOKBody
select {
case err := <-errCh:
if err != nil {
return nil, err
}
case status = <-statusCh:
// Exit log stream
close(stop)
}
if status != 0 {
return nil, errors.New("Build exited with non-zero status: " + strconv.FormatInt(status, 10))
if status.StatusCode != 0 {
return nil, fmt.Errorf(
"Build exited with non-zero status %s", strconv.FormatInt(status.StatusCode, 10))
}
fmt.Fprintln(out, "Build exited with status "+strconv.FormatInt(status, 10))
fmt.Fprintln(out, "Build exited with status "+strconv.FormatInt(status.StatusCode, 10))

// Save build as new image and create a container
imgName := "inertia-build/" + d.Name
Expand Down
2 changes: 1 addition & 1 deletion daemon/inertiad/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func logHandler(w http.ResponseWriter, r *http.Request) {
Stream: stream,
})
if err != nil {
if docker.IsErrContainerNotFound(err) {
if docker.IsErrNotFound(err) {
logger.WriteErr(err.Error(), http.StatusNotFound)
} else {
logger.WriteErr(err.Error(), http.StatusInternalServerError)
Expand Down

0 comments on commit 0b27811

Please sign in to comment.