Skip to content

Commit

Permalink
Fix kubeadm upgrade plan issue with FQDN nodes names
Browse files Browse the repository at this point in the history
the fix introduced in kubernetes#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
  • Loading branch information
clementnuss committed Jul 29, 2022
1 parent 9530339 commit 1459fdf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/kubeadm/app/cmd/upgrade/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1459fdf

Please sign in to comment.