docker: always use API version negotiation when initializing clients (#24237)

During a refactoring of the docker driver in #23966 we introduced a bug: API
version negotiation option was not passed to every new client call.
This commit is contained in:
Piotr Kazmierczak
2024-10-17 15:23:14 +02:00
committed by GitHub
parent d12128c380
commit 1ac14f4869
3 changed files with 15 additions and 3 deletions

3
.changelog/24237.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
docker: Always negotiate API version when initializing clients
```

View File

@@ -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)
}

View File

@@ -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)
}