From b1904e5fbc19e8f96c65f7dbb0a5829d48ba7735 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Wed, 1 Oct 2025 14:42:58 +0200 Subject: [PATCH] Wait up to 30 seconds for config drive Handle Virtual Media ISO (sr0) appearing later Issue: https://bugs.launchpad.net/ironic-python-agent-builder/+bug/2126068 Change-Id: I185f0955d86767784ea6b68c01ffc484c83c61ae Signed-off-by: Mathieu Parent (cherry picked from commit 9aca8fd38fbef23719675bb71fd12d133f228460) --- .../ironic-agent-resolve-config-drive.service | 2 ++ ...ironic-python-agent-resolve-configdrive.sh | 22 +++++++++++++------ ...ait-config-drive-30s-3c51adba5fddc8a2.yaml | 4 ++++ 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/wait-config-drive-30s-3c51adba5fddc8a2.yaml diff --git a/dib/ironic-python-agent-ramdisk/static/etc/systemd/system/ironic-agent-resolve-config-drive.service b/dib/ironic-python-agent-ramdisk/static/etc/systemd/system/ironic-agent-resolve-config-drive.service index fa367eb..9ffbcba 100644 --- a/dib/ironic-python-agent-ramdisk/static/etc/systemd/system/ironic-agent-resolve-config-drive.service +++ b/dib/ironic-python-agent-ramdisk/static/etc/systemd/system/ironic-agent-resolve-config-drive.service @@ -3,6 +3,8 @@ Description=Ironic agent config drive setup Wants=network-pre.target Before=network-pre.target After=local-fs.target +Before=glean.service +Before=system-glean.slice [Service] ExecStart=/bin/bash /usr/local/bin/ironic-python-agent-resolve-configdrive.sh diff --git a/dib/ironic-python-agent-ramdisk/static/usr/local/bin/ironic-python-agent-resolve-configdrive.sh b/dib/ironic-python-agent-ramdisk/static/usr/local/bin/ironic-python-agent-resolve-configdrive.sh index 0f6cc4e..20b4f2d 100755 --- a/dib/ironic-python-agent-ramdisk/static/usr/local/bin/ironic-python-agent-resolve-configdrive.sh +++ b/dib/ironic-python-agent-ramdisk/static/usr/local/bin/ironic-python-agent-resolve-configdrive.sh @@ -10,19 +10,27 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin # Inspired by/based on glean-early.sh # https://opendev.org/opendev/glean/src/branch/master/glean/init/glean-early.sh -# NOTE(TheJulia): We care about iso images, and would expect lower case as a -# result. In the case of VFAT partitions, they would be upper case. -CONFIG_DRIVE_LABEL="config-2" - -# Identify the number of devices -device_count=$(lsblk -o PATH,LABEL | grep -c $CONFIG_DRIVE_LABEL || true) - # Identify if we have an a publisher id set publisher_id="" if grep -q "ir_pub_id" /proc/cmdline; then publisher_id=$(cat /proc/cmdline | sed -e 's/^.*ir_pub_id=//' -e 's/ .*$//') fi +# NOTE(TheJulia): We care about iso images, and would expect lower case as a +# result. In the case of VFAT partitions, they would be upper case. +CONFIG_DRIVE_LABEL="config-2" + +i=0 +while [ $i -lt 30 ] ; do + i=$((i + 1)) + + # Identify the number of devices + device_count=$(lsblk -o PATH,LABEL | grep -c $CONFIG_DRIVE_LABEL || true) + + [ $device_count -lt 1 ] || break + sleep 1 +done + if [ $device_count -lt 1 ]; then # Nothing to do here, exit! exit 0 diff --git a/releasenotes/notes/wait-config-drive-30s-3c51adba5fddc8a2.yaml b/releasenotes/notes/wait-config-drive-30s-3c51adba5fddc8a2.yaml new file mode 100644 index 0000000..5220569 --- /dev/null +++ b/releasenotes/notes/wait-config-drive-30s-3c51adba5fddc8a2.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Wait config drive up to 30 seconds. This ensure that network data is available to Glean.