From f324476b59db5eb593ca50611a4a04ff4eee648c Mon Sep 17 00:00:00 2001 From: Piotr Kazmierczak <470696+pkazmierczak@users.noreply.github.com> Date: Thu, 17 Oct 2024 11:41:54 +0200 Subject: [PATCH 1/2] docker: always use API version negotiation when initializing --- drivers/docker/docklog/docker_logger.go | 9 +++++++-- drivers/docker/driver.go | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/docker/docklog/docker_logger.go b/drivers/docker/docklog/docker_logger.go index f8a4631278c..15fbe68c541 100644 --- a/drivers/docker/docklog/docker_logger.go +++ b/drivers/docker/docklog/docker_logger.go @@ -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) } diff --git a/drivers/docker/driver.go b/drivers/docker/driver.go index f24b0ced783..63a5762826e 100644 --- a/drivers/docker/driver.go +++ b/drivers/docker/driver.go @@ -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) } From eff150bf941ba2350d6bc9890ba12691cf7fa176 Mon Sep 17 00:00:00 2001 From: Piotr Kazmierczak <470696+pkazmierczak@users.noreply.github.com> Date: Thu, 17 Oct 2024 12:19:52 +0200 Subject: [PATCH 2/2] cl --- .changelog/24237.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/24237.txt diff --git a/.changelog/24237.txt b/.changelog/24237.txt new file mode 100644 index 00000000000..33ff71fac51 --- /dev/null +++ b/.changelog/24237.txt @@ -0,0 +1,3 @@ +```release-note:bug +docker: Always negotiate API version when initializing clients +```