Skip to content

Commit

Permalink
backport of commit 1ac14f4
Browse files Browse the repository at this point in the history
  • Loading branch information
pkazmierczak authored Oct 17, 2024
1 parent 6c3f222 commit 709fc87
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/24237.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
docker: Always negotiate API version when initializing clients
```
9 changes: 7 additions & 2 deletions drivers/docker/docklog/docker_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,18 @@ func (d *dockerLogger) getDockerClient(opts *StartOpts) (*client.Client, error)
d.logger.Debug("using TLS client connection to docker", "endpoint", opts.Endpoint)
newClient, err = client.NewClientWithOpts(
client.WithHost(opts.Endpoint),
client.WithTLSClientConfig(opts.TLSCA, opts.TLSCert, opts.TLSKey))
client.WithTLSClientConfig(opts.TLSCA, opts.TLSCert, opts.TLSKey),
client.WithAPIVersionNegotiation(),
)
if err != nil {
merr.Errors = append(merr.Errors, err)
}
} else {
d.logger.Debug("using plaintext client connection to docker", "endpoint", opts.Endpoint)
newClient, err = client.NewClientWithOpts(client.WithHost(opts.Endpoint))
newClient, err = client.NewClientWithOpts(
client.WithHost(opts.Endpoint),
client.WithAPIVersionNegotiation(),
)
if err != nil {
merr.Errors = append(merr.Errors, err)
}
Expand Down
6 changes: 5 additions & 1 deletion drivers/docker/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1927,13 +1927,17 @@ func (d *Driver) newDockerClient(timeout time.Duration) (*client.Client, error)
newClient, err = client.NewClientWithOpts(
client.WithHost(dockerEndpoint),
client.WithTLSClientConfig(ca, cert, key),
client.WithAPIVersionNegotiation(),
)
if err != nil {
merr.Errors = append(merr.Errors, err)
}
} else {
d.logger.Debug("using standard client connection", "endpoint", dockerEndpoint)
newClient, err = client.NewClientWithOpts(client.WithHost(dockerEndpoint))
newClient, err = client.NewClientWithOpts(
client.WithHost(dockerEndpoint),
client.WithAPIVersionNegotiation(),
)
if err != nil {
merr.Errors = append(merr.Errors, err)
}
Expand Down

0 comments on commit 709fc87

Please sign in to comment.