Fix kubeadm upgrade plan
issue with FQDN nodes names
the fix introduced in #110634 also introduces a bug preventing `kubeadm upgrade plan` from running on nodes having a different `os.Hostname()` than node name. concretely, for a node `titi.company.ch`, `os.Hostname()` will return `titi`, while the full node name is actually `titi.company.ch`. this simple fix uses the `cfg.NodeRegistration.Name` instead, which fixes the issue on my nodes with a FQDN node name Keep previous hostname retrieval as fallback for dupURL CRI fix
This commit is contained in:
parent
95303390ac
commit
1459fdf7cf
@ -232,9 +232,14 @@ func enforceRequirements(flags *applyPlanFlags, args []string, dryRun bool, upgr
|
||||
if dupURLScheme {
|
||||
socket := strings.ReplaceAll(cfg.NodeRegistration.CRISocket, kubeadmapiv1.DefaultContainerRuntimeURLScheme+"://", "")
|
||||
cfg.NodeRegistration.CRISocket = kubeadmapiv1.DefaultContainerRuntimeURLScheme + "://" + socket
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.Wrapf(err, "failed to get hostname")
|
||||
var hostname string
|
||||
if len(cfg.NodeRegistration.Name) > 0 {
|
||||
hostname = cfg.NodeRegistration.Name
|
||||
} else {
|
||||
hostname, err = os.Hostname()
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.Wrapf(err, "failed to get hostname")
|
||||
}
|
||||
}
|
||||
klog.V(2).Infof("ensuring that Node %q has a CRI socket annotation with correct URL scheme %q", hostname, cfg.NodeRegistration.CRISocket)
|
||||
if err := patchnodephase.AnnotateCRISocket(client, hostname, cfg.NodeRegistration.CRISocket); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user