Skip to content

Commit 20f2660

Browse files
Merge pull request #4955 from Prashanth684/okd-scos
OKD-239: Consolidate OpenStack and PowerVS hostname handling into mco-hostname script
2 parents 85ff8f1 + 19a888b commit 20f2660

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

templates/common/_base/files/usr-local-bin-mco-hostname.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ path: "/usr/local/bin/mco-hostname"
33
contents:
44
inline: |
55
#!/bin/bash
6+
set -euo pipefail
7+
68
# First, we need to wait until DHCP finishes and the node has a non-`localhost`
79
# hostname before `kubelet.service` starts.
810
# That's the `--wait` argument as used by `node-valid-hostname.service`.
@@ -57,9 +59,27 @@ contents:
5759
exit 0
5860
}
5961
62+
set_openstack_hostname() {
63+
# Read metadata written by afterburn service
64+
. /run/metadata/afterburn
65+
66+
# node-valid-hostname sets persistent hostname from /proc/sys/kernel/hostname
67+
echo "$AFTERBURN_OPENSTACK_HOSTNAME" > /proc/sys/kernel/hostname
68+
}
69+
70+
set_powervs_hostname() {
71+
# Read metadata written by afterburn service
72+
. /run/metadata/afterburn
73+
74+
# node-valid-hostname sets persistent hostname from /proc/sys/kernel/hostname
75+
echo "$AFTERBURN_POWERVS_LOCAL_HOSTNAME" > /proc/sys/kernel/hostname
76+
}
77+
6078
arg=${1}; shift;
6179
case "${arg}" in
6280
--wait) wait_localhost;;
6381
--gcp) set_gcp_hostname;;
82+
--openstack) set_openstack_hostname;;
83+
--powervs) set_powervs_hostname;;
6484
*) echo "Unhandled arg $arg"; exit 1
6585
esac

templates/common/openstack/files/usr-local-bin-openstack-afterburn-hostname.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

templates/common/openstack/units/afterburn-hostname.service.yaml renamed to templates/common/openstack/units/openstack-hostname.service.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: afterburn-hostname.service
1+
name: openstack-hostname.service
22
enabled: true
33
contents: |
44
[Unit]
@@ -9,14 +9,17 @@ contents: |
99
After=NetworkManager-wait-online.service
1010
# Run before hostname checks
1111
Before=node-valid-hostname.service
12+
# We require afterburn to have run first
13+
Requires=afterburn.service
14+
After=afterburn.service
1215
1316
[Service]
1417
# Would prefer to do Restart=on-failure instead of this bash retry loop, but
1518
# the version of systemd we have right now doesn't support it. It should be
1619
# available in systemd v244 and higher.
1720
ExecStart=/bin/bash -c " \
1821
until \
19-
/usr/local/bin/openstack-afterburn-hostname; \
22+
/usr/local/bin/mco-hostname --openstack; \
2023
do \
2124
sleep 10; \
2225
done"
@@ -26,4 +29,4 @@ contents: |
2629
RemainAfterExit=true
2730
2831
[Install]
29-
WantedBy=network-online.target
32+
WantedBy=node-valid-hostname.service
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: afterburn-hostname.service
1+
name: powervs-hostname.service
22
enabled: true
33
contents: |
44
[Unit]
@@ -9,10 +9,13 @@ contents: |
99
After=NetworkManager-wait-online.service
1010
# Run before hostname checks
1111
Before=node-valid-hostname.service
12+
# We require afterburn to have run first
13+
Requires=afterburn.service
14+
After=afterburn.service
1215
1316
[Service]
14-
ExecStart=/usr/bin/afterburn --provider powervs --hostname=/etc/hostname
1517
Type=oneshot
18+
ExecStart=/usr/local/bin/mco-hostname --powervs
1619
1720
[Install]
18-
WantedBy=network-online.target
21+
WantedBy=node-valid-hostname.service

0 commit comments

Comments
 (0)