dockershim: Fix negotiating docker API version

API version negotiation needs to happen before any meaningful docker
calls, including simple commands such as "/version".
This commit is contained in:
Yu-Ju Hong 2019-04-15 11:29:58 -07:00
parent 631bf8cbc8
commit 903f635ab3

View File

@ -85,15 +85,12 @@ func newKubeDockerClient(dockerClient *dockerapi.Client, requestTimeout, imagePu
timeout: requestTimeout, timeout: requestTimeout,
imagePullProgressDeadline: imagePullProgressDeadline, imagePullProgressDeadline: imagePullProgressDeadline,
} }
// Notice that this assumes that docker is running before kubelet is started. // Notice that this assumes that docker is running before kubelet is started.
v, err := k.Version() ctx, cancel := k.getTimeoutContext()
if err != nil { defer cancel()
klog.Errorf("failed to retrieve docker version: %v", err) dockerClient.NegotiateAPIVersion(ctx)
klog.Warningf("Using empty version for docker client, this may sometimes cause compatibility issue.")
} else {
// Update client version with real api version.
dockerClient.NegotiateAPIVersionPing(dockertypes.Ping{APIVersion: v.APIVersion})
}
return k return k
} }