Skip to content

Commit

Permalink
fix(docker): Negotiate api version with server (#122)
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <cegao@tensorchord.ai>
  • Loading branch information
gaocegege authored May 9, 2022
1 parent da4d1a0 commit 870cebd
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/midi/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var CommandDestroy = &cli.Command{
}

func destroy(clicontext *cli.Context) error {
dockerClient, err := docker.NewClient()
dockerClient, err := docker.NewClient(clicontext.Context)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/midi/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func up(clicontext *cli.Context) error {
}
gpu := builder.GPUEnabled()

dockerClient, err := docker.NewClient()
dockerClient, err := docker.NewClient(clicontext.Context)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (b generalBuilder) Build(ctx context.Context) error {
// Load the image to docker host.
eg.Go(func() error {
defer pipeR.Close()
dockerClient, err := docker.NewClient()
dockerClient, err := docker.NewClient(ctx)
if err != nil {
return errors.Wrap(err, "failed to new docker client")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/buildkitd/buildkitd.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (c generalClient) Close() error {
// that can be used to connect to it.
func (c *generalClient) maybeStart(ctx context.Context,
runningTimeout, connectingTimeout time.Duration) (string, error) {
dockerClient, err := docker.NewClient()
dockerClient, err := docker.NewClient(ctx)
if err != nil {
return "", err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ type generalClient struct {
*client.Client
}

func NewClient() (Client, error) {
func NewClient(ctx context.Context) (Client, error) {
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
return nil, err
}
cli.NegotiateAPIVersion(ctx)
return generalClient{cli}, nil
}

Expand Down

0 comments on commit 870cebd

Please sign in to comment.