Skip to content

OKD-239: Consolidate OpenStack and PowerVS hostname handling into mco-hostname script #4955

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

Merged
merged 1 commit into from
Apr 7, 2025
Merged
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
20 changes: 20 additions & 0 deletions templates/common/_base/files/usr-local-bin-mco-hostname.yaml
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@ path: "/usr/local/bin/mco-hostname"
contents:
inline: |
#!/bin/bash
set -euo pipefail
# First, we need to wait until DHCP finishes and the node has a non-`localhost`
# hostname before `kubelet.service` starts.
# That's the `--wait` argument as used by `node-valid-hostname.service`.
@@ -57,9 +59,27 @@ contents:
exit 0
}
set_openstack_hostname() {
# Read metadata written by afterburn service
. /run/metadata/afterburn
# node-valid-hostname sets persistent hostname from /proc/sys/kernel/hostname
echo "$AFTERBURN_OPENSTACK_HOSTNAME" > /proc/sys/kernel/hostname
}
set_powervs_hostname() {
# Read metadata written by afterburn service
. /run/metadata/afterburn
# node-valid-hostname sets persistent hostname from /proc/sys/kernel/hostname
echo "$AFTERBURN_POWERVS_LOCAL_HOSTNAME" > /proc/sys/kernel/hostname
}
arg=${1}; shift;
case "${arg}" in
--wait) wait_localhost;;
--gcp) set_gcp_hostname;;
--openstack) set_openstack_hostname;;
--powervs) set_powervs_hostname;;
*) echo "Unhandled arg $arg"; exit 1
esac

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: afterburn-hostname.service
name: openstack-hostname.service
enabled: true
contents: |
[Unit]
@@ -9,14 +9,17 @@ contents: |
After=NetworkManager-wait-online.service
# Run before hostname checks
Before=node-valid-hostname.service
# We require afterburn to have run first
Requires=afterburn.service
After=afterburn.service
[Service]
# Would prefer to do Restart=on-failure instead of this bash retry loop, but
# the version of systemd we have right now doesn't support it. It should be
# available in systemd v244 and higher.
ExecStart=/bin/bash -c " \
until \
/usr/local/bin/openstack-afterburn-hostname; \
/usr/local/bin/mco-hostname --openstack; \
do \
sleep 10; \
done"
@@ -26,4 +29,4 @@ contents: |
RemainAfterExit=true
[Install]
WantedBy=network-online.target
WantedBy=node-valid-hostname.service
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: afterburn-hostname.service
name: powervs-hostname.service
enabled: true
contents: |
[Unit]
@@ -9,10 +9,13 @@ contents: |
After=NetworkManager-wait-online.service
# Run before hostname checks
Before=node-valid-hostname.service
# We require afterburn to have run first
Requires=afterburn.service
After=afterburn.service
[Service]
ExecStart=/usr/bin/afterburn --provider powervs --hostname=/etc/hostname
Type=oneshot
ExecStart=/usr/local/bin/mco-hostname --powervs
[Install]
WantedBy=network-online.target
WantedBy=node-valid-hostname.service