From 2d4307db9fe2f1050af6db7eefc83969b975c699 Mon Sep 17 00:00:00 2001 From: "Rostislav M. Georgiev" Date: Fri, 12 Apr 2019 17:25:11 +0300 Subject: [PATCH] kubeadm: Don't error out on join with --cri-socket override In the case where newControlPlane is true we don't go through getNodeRegistration() and initcfg.NodeRegistration.CRISocket is empty. This forces DetectCRISocket() to be called later on, and if there is more than one CRI installed on the system, it will error out, while asking for the user to provide an override for the CRI socket. Even if the user provides an override, the call to DetectCRISocket() can happen too early and thus ignore it (while still erroring out). However, if newControlPlane == true, initcfg.NodeRegistration is not used at all and it's overwritten later on. Thus it's necessary to supply some default value, that will avoid the call to DetectCRISocket() and as initcfg.NodeRegistration is discarded, setting whatever value here is harmless. Signed-off-by: Rostislav M. Georgiev --- cmd/kubeadm/app/util/config/cluster.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/kubeadm/app/util/config/cluster.go b/cmd/kubeadm/app/util/config/cluster.go index 840a40869e9..41f04039594 100644 --- a/cmd/kubeadm/app/util/config/cluster.go +++ b/cmd/kubeadm/app/util/config/cluster.go @@ -93,6 +93,15 @@ func getInitConfigurationFromCluster(kubeconfigDir string, client clientset.Inte if err := getAPIEndpoint(configMap.Data, initcfg.NodeRegistration.Name, &initcfg.LocalAPIEndpoint); err != nil { return nil, errors.Wrap(err, "failed to getAPIEndpoint") } + } else { + // In the case where newControlPlane is true we don't go through getNodeRegistration() and initcfg.NodeRegistration.CRISocket is empty. + // This forces DetectCRISocket() to be called later on, and if there is more than one CRI installed on the system, it will error out, + // while asking for the user to provide an override for the CRI socket. Even if the user provides an override, the call to + // DetectCRISocket() can happen too early and thus ignore it (while still erroring out). + // However, if newControlPlane == true, initcfg.NodeRegistration is not used at all and it's overwritten later on. + // Thus it's necessary to supply some default value, that will avoid the call to DetectCRISocket() and as + // initcfg.NodeRegistration is discarded, setting whatever value here is harmless. + initcfg.NodeRegistration.CRISocket = constants.DefaultDockerCRISocket } return initcfg, nil }