mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-05 11:12:03 +00:00
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:
@@ -232,9 +232,14 @@ func enforceRequirements(flags *applyPlanFlags, args []string, dryRun bool, upgr
|
|||||||
if dupURLScheme {
|
if dupURLScheme {
|
||||||
socket := strings.ReplaceAll(cfg.NodeRegistration.CRISocket, kubeadmapiv1.DefaultContainerRuntimeURLScheme+"://", "")
|
socket := strings.ReplaceAll(cfg.NodeRegistration.CRISocket, kubeadmapiv1.DefaultContainerRuntimeURLScheme+"://", "")
|
||||||
cfg.NodeRegistration.CRISocket = kubeadmapiv1.DefaultContainerRuntimeURLScheme + "://" + socket
|
cfg.NodeRegistration.CRISocket = kubeadmapiv1.DefaultContainerRuntimeURLScheme + "://" + socket
|
||||||
hostname, err := os.Hostname()
|
var hostname string
|
||||||
if err != nil {
|
if len(cfg.NodeRegistration.Name) > 0 {
|
||||||
return nil, nil, nil, errors.Wrapf(err, "failed to get hostname")
|
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)
|
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 {
|
if err := patchnodephase.AnnotateCRISocket(client, hostname, cfg.NodeRegistration.CRISocket); err != nil {
|
||||||
|
Reference in New Issue
Block a user