dockershim: Fix negotiating docker API version

API version negotiation needs to happen before any meaningful docker
calls, including simple commands such as "/version".
k3s-v1.15.3
Yu-Ju Hong 2019-04-15 11:29:58 -07:00
parent 631bf8cbc8
commit 903f635ab3
1 changed files with 5 additions and 8 deletions

View File

@ -85,15 +85,12 @@ func newKubeDockerClient(dockerClient *dockerapi.Client, requestTimeout, imagePu
timeout: requestTimeout,
imagePullProgressDeadline: imagePullProgressDeadline,
}
// Notice that this assumes that docker is running before kubelet is started.
v, err := k.Version()
if err != nil {
klog.Errorf("failed to retrieve docker version: %v", err)
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})
}
ctx, cancel := k.getTimeoutContext()
defer cancel()
dockerClient.NegotiateAPIVersion(ctx)
return k
}