Skip to content

Conversation

@ehsjoar
Copy link
Contributor

@ehsjoar ehsjoar commented Feb 2, 2026

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

@ehsjoar ehsjoar requested review from e-minguez and hardys February 2, 2026 07:41
if [ ! -f "${META_DATA_FILE}" ]; then
umount /mnt
echo "No meta_data.json found, skipping hostname configuration"
exit 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

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?

if [ ! -f "${META_DATA_FILE}" ]; then
umount /mnt
echo "No meta_data.json found, skipping hostname configuration"
exit 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update configure-network.sh in quickstart/metal3.adoc to reflect telco-cloud-examples

3 participants