Merge pull request #121295 from SataQiu/clean-kubeadm-20231017

kubeadm: remove reference to UnknownCRISocket from getInitConfigurationFromCluster
This commit is contained in:
Kubernetes Prow Robot 2023-10-18 06:06:59 +02:00 committed by GitHub
commit 478c934c1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions

View File

@ -59,7 +59,8 @@ func FetchInitConfigurationFromCluster(client clientset.Interface, printer outpu
}
// Apply dynamic defaults
if err := SetInitDynamicDefaults(cfg, false); err != nil {
// NB. skip CRI detection here because it won't be used at all and will be overridden later
if err := SetInitDynamicDefaults(cfg, true); err != nil {
return nil, err
}
@ -116,15 +117,6 @@ func getInitConfigurationFromCluster(kubeconfigDir string, client clientset.Inte
if err := getAPIEndpoint(client, 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.UnknownCRISocket
}
return initcfg, nil
}

View File

@ -646,6 +646,12 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
if !rt.newControlPlane && (cfg.LocalAPIEndpoint.AdvertiseAddress != "1.2.3.4" || cfg.LocalAPIEndpoint.BindPort != 1234) {
t.Errorf("invalid cfg.LocalAPIEndpoint: %v", cfg.LocalAPIEndpoint)
}
if !rt.newControlPlane && (cfg.NodeRegistration.Name != nodeName || cfg.NodeRegistration.CRISocket != "myCRIsocket" || len(cfg.NodeRegistration.Taints) != 1) {
t.Errorf("invalid cfg.NodeRegistration: %v", cfg.NodeRegistration)
}
if rt.newControlPlane && len(cfg.NodeRegistration.CRISocket) > 0 {
t.Errorf("invalid cfg.NodeRegistration.CRISocket: expected empty CRISocket, but got %v", cfg.NodeRegistration.CRISocket)
}
if _, ok := cfg.ComponentConfigs[componentconfigs.KubeletGroup]; !ok {
t.Errorf("no cfg.ComponentConfigs[%q]", componentconfigs.KubeletGroup)
}