From 9b397bd34ecb1df51db7c1ec75a112b949cade32 Mon Sep 17 00:00:00 2001 From: Doug Szumski Date: Wed, 13 Aug 2025 16:05:40 +0100 Subject: [PATCH] Don't fail early if no config drive found The use of pipefail means that we fail early if we don't find a matching config drive. This is because grep returns exit code 1 if no match is found. We can either drop the pipefail setting, or force grep to return 0. This allows us to exit gracefully later in the script with code 0. Closes-Bug: #2120574 Change-Id: I84e348b44b041672ded800a967dae18437f16bba Signed-off-by: Doug Szumski --- .../usr/local/bin/ironic-python-agent-resolve-configdrive.sh | 2 +- .../fix-early-fail-if-no-config-drive-2085609b044ac85f.yaml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-early-fail-if-no-config-drive-2085609b044ac85f.yaml 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 84a91e0..0f6cc4e 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 @@ -15,7 +15,7 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin CONFIG_DRIVE_LABEL="config-2" # Identify the number of devices -device_count=$(lsblk -o PATH,LABEL | grep $CONFIG_DRIVE_LABEL | wc -l) +device_count=$(lsblk -o PATH,LABEL | grep -c $CONFIG_DRIVE_LABEL || true) # Identify if we have an a publisher id set publisher_id="" diff --git a/releasenotes/notes/fix-early-fail-if-no-config-drive-2085609b044ac85f.yaml b/releasenotes/notes/fix-early-fail-if-no-config-drive-2085609b044ac85f.yaml new file mode 100644 index 0000000..148c2d8 --- /dev/null +++ b/releasenotes/notes/fix-early-fail-if-no-config-drive-2085609b044ac85f.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes a minor issue where the resolve config drive script fails early if + no config drive is found.