From 1a311235bab8cd31f8b3a63b03c34097f1d52818 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 29 Jun 2017 22:24:49 -0700 Subject: [PATCH] Always perform version-negotiation If a client is initialized without a specific version set, version negotiation would not be functional. This patch changes the behavior to always perform version negotation (if called), in which case the "current" (maximum supported API version) is used as a default. Signed-off-by: Sebastiaan van Stijn Upstream-commit: 5975dc4b4b8a6fa2e0edd1f1b113e7f66dad732b Component: engine --- components/engine/client/client.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/engine/client/client.go b/components/engine/client/client.go index 222aa50f11..62a3db360a 100644 --- a/components/engine/client/client.go +++ b/components/engine/client/client.go @@ -260,8 +260,13 @@ func (cli *Client) NegotiateAPIVersionPing(p types.Ping) { p.APIVersion = "1.24" } - // if server version is lower than the current cli, downgrade - if versions.LessThan(p.APIVersion, cli.ClientVersion()) { + // if the client is not initialized with a version, start with the latest supported version + if cli.version == "" { + cli.version = api.DefaultVersion + } + + // if server version is lower than the maximum version supported by the Client, downgrade + if versions.LessThan(p.APIVersion, api.DefaultVersion) { cli.version = p.APIVersion } }