mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 07:39:22 +00:00
Merge pull request #121295 from SataQiu/clean-kubeadm-20231017
kubeadm: remove reference to UnknownCRISocket from getInitConfigurationFromCluster
This commit is contained in:
commit
478c934c1a
@ -59,7 +59,8 @@ func FetchInitConfigurationFromCluster(client clientset.Interface, printer outpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply dynamic defaults
|
// 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
|
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 {
|
if err := getAPIEndpoint(client, initcfg.NodeRegistration.Name, &initcfg.LocalAPIEndpoint); err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to getAPIEndpoint")
|
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
|
return initcfg, nil
|
||||||
}
|
}
|
||||||
|
@ -646,6 +646,12 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
|
|||||||
if !rt.newControlPlane && (cfg.LocalAPIEndpoint.AdvertiseAddress != "1.2.3.4" || cfg.LocalAPIEndpoint.BindPort != 1234) {
|
if !rt.newControlPlane && (cfg.LocalAPIEndpoint.AdvertiseAddress != "1.2.3.4" || cfg.LocalAPIEndpoint.BindPort != 1234) {
|
||||||
t.Errorf("invalid cfg.LocalAPIEndpoint: %v", cfg.LocalAPIEndpoint)
|
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 {
|
if _, ok := cfg.ComponentConfigs[componentconfigs.KubeletGroup]; !ok {
|
||||||
t.Errorf("no cfg.ComponentConfigs[%q]", componentconfigs.KubeletGroup)
|
t.Errorf("no cfg.ComponentConfigs[%q]", componentconfigs.KubeletGroup)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user