Skip to content

Commit

Permalink
Restore old behavior of not setting empty hostnames
Browse files Browse the repository at this point in the history
The refactoring in flatcar#21
caused hostnames to be set unconditionally compared to the old behavior
of only setting the hostname if it not empty.

When running coreos-cloudinit with datasources that do not provide
metadata such as the `file` datasource, the refactored code caused the
hostname to always be reset to `localhost`. This leads to various
problems like preventing k8s nodes from joining their cluster.

This change restores the old behavior by not applying empty hostnames.

Fixes flatcar/Flatcar#1262
  • Loading branch information
MichaelEischer committed Jan 15, 2024
1 parent 47bc4cf commit 47d54a3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions initialize/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type CloudConfigUnit interface {
}

func ApplyHostname(hostname string) error {
if hostname == "" {
return nil
}
if err := system.SetHostname(hostname); err != nil {
return fmt.Errorf("error setting hostname: %w", err)
}
Expand Down

0 comments on commit 47d54a3

Please sign in to comment.