Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-45459: Remove trailing period from hostnames #4966

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions templates/common/_base/files/usr-local-bin-mco-hostname.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ contents:
do
sleep 1
done
echo "node identified as $(</proc/sys/kernel/hostname)"

# Some cloud platforms may assign a hostname with a trailing dot.
# However, tools like `hostnamectl` (used by systemd) do not allow trailing dots,
# so we strip the trailing dot before applying the hostname.
HOSTNAME="$(</proc/sys/kernel/hostname)"
CLEAN_HOSTNAME="${HOSTNAME%.}"
Comment on lines +27 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a WHY comment here as this is mildly odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I have added a comment

echo "node identified as $CLEAN_HOSTNAME"
echo "saving hostname to prevent NetworkManager from ever unsetting it"
hostnamectl set-hostname --static --transient $(</proc/sys/kernel/hostname)
hostnamectl set-hostname --static --transient "$CLEAN_HOSTNAME"
exit 0
}

Expand Down