Addresses 1031 - Update configure-network.sh#1032
Addresses 1031 - Update configure-network.sh#1032ehsjoar wants to merge 1 commit intosuse-edge:mainfrom
Conversation
…c to reflect telco-cloud-examples
| if [ ! -f "${META_DATA_FILE}" ]; then | ||
| umount /mnt | ||
| echo "No meta_data.json found, skipping hostname configuration" | ||
| exit 0 |
There was a problem hiding this comment.
So if there is no metadata the script just finishes? Shouldn't it continue instead?
If it should exit, then the message should be something like "No meta_data.json found, exiting" because otherwise it seems it continues.
There was a problem hiding this comment.
There are certain fields which are always set in the meta-data, even though the user-provided metaData in the BMH spec is optional:
https://github.com/metal3-io/baremetal-operator/blob/main/pkg/provisioner/ironic/ironic.go#L1209
So I think the exit here is OK, although it would also be fine if we just moved the subsequent lines into an else.
There was a problem hiding this comment.
What I'm saying is to check if metadata exists, if it does, set hostname, if it doesn't, continue getting the network data, something like:
META_DATA_FILE="/mnt/openstack/latest/meta_data.json"
if [ -f "${META_DATA_FILE}" ]; then
DESIRED_HOSTNAME=$(cat /mnt/openstack/latest/meta_data.json | tr ',{}' '\n' | grep '"metal3-name"' | sed 's/.*\"metal3-name\": \"\(.*\)\"/\1/')
echo "${DESIRED_HOSTNAME}" > /etc/hostname
else
umount /mnt
echo "No meta_data.json found, skipping hostname configuration"
fi
Why unmounting /mnt though?
There was a problem hiding this comment.
This aligns with what was already merged via suse-edge/telco-cloud-examples#80 - I think in practice this will work OK, but we can certainly seek to iterate on both docs and examples in a follow-up if needed
| if [ ! -f "${META_DATA_FILE}" ]; then | ||
| umount /mnt | ||
| echo "No meta_data.json found, skipping hostname configuration" | ||
| exit 0 |
| if [ ! -f "${META_DATA_FILE}" ]; then | ||
| umount /mnt | ||
| echo "No meta_data.json found, skipping hostname configuration" | ||
| exit 0 |
There was a problem hiding this comment.
This aligns with what was already merged via suse-edge/telco-cloud-examples#80 - I think in practice this will work OK, but we can certainly seek to iterate on both docs and examples in a follow-up if needed
This is to address situations where we don't get any network data but still want to set the hostaname (e.g. in the case of Sylva). This MR fixes #1031