From ff3f328f0b7be39d4a53473b7f18d052323bfae1 Mon Sep 17 00:00:00 2001 From: Raphael Glon Date: Thu, 1 Aug 2019 19:41:58 +0200 Subject: [PATCH] Ansible: fix partition_configdrive for logical root_devices If the node root_device is a logical drive (like an md array, or a logical volume), partition_configdrive.sh was not working correctly. Change-Id: Ida4f91efba0f38f20cd80dd6b6162a77af8d6b78 Story: #2006334 Task: #36082 --- .../deploy/files/partition_configdrive.sh | 22 +++++++++++++++++-- .../notes/bug-2006334-0cd8f59073f56241.yaml | 7 ++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/bug-2006334-0cd8f59073f56241.yaml diff --git a/ironic/drivers/modules/ansible/playbooks/roles/deploy/files/partition_configdrive.sh b/ironic/drivers/modules/ansible/playbooks/roles/deploy/files/partition_configdrive.sh index 24ae8e8bab..cdff0e4fda 100755 --- a/ironic/drivers/modules/ansible/playbooks/roles/deploy/files/partition_configdrive.sh +++ b/ironic/drivers/modules/ansible/playbooks/roles/deploy/files/partition_configdrive.sh @@ -43,7 +43,7 @@ DEVICE="$1" # We need to run partx -u to ensure all partitions are visible so the # following blkid command returns partitions just imaged to the device -partx -u $DEVICE || fail "running partx -u $DEVICE" +partx -u $DEVICE || true # todo(jayf): partx -u doesn't work in all cases, but partprobe fails in # devstack. We run both commands now as a temporary workaround for bug 1433812 @@ -67,8 +67,26 @@ if [ -z $EXISTING_PARTITION ]; then # any conflict with any other pre-existing partlabel PARTLABEL=config-$(< /dev/urandom tr -dc a-z0-9 | head -c 5) sgdisk -n 0:-64MB:0 -c 0:$PARTLABEL $DEVICE || fail "creating configdrive on ${DEVICE}" - partprobe + ISO_PARTITION=/dev/disk/by-partlabel/$PARTLABEL + if ! [ -b $ISO_PARTITION ]; then + # In some cases like md arrays (or any other logical device) + # /dev/disk/by-partlabel/$PARTLABEL file is not created. + # In such case, we fallback to this method. Note: this method could + # be the only one used, if only we could assert it is 100% working. + + partprobe || true + + # The call below is not useless: for some unexplained reason, not + # calling blkid here causes the next subshell blkid calls to + # sometimes output outdated info... (sleeps, retries, partprobe or + # partx calls don't change the outcome...). + # If anyone knows why, please feel free to replace the workaround + # below with the proper fix. + blkid >/dev/null 2>&1 + + ISO_PARTITION=$(blkid -l -o device -t PARTLABEL=$PARTLABEL) + fi else log "Working on MBR only device $DEVICE" diff --git a/releasenotes/notes/bug-2006334-0cd8f59073f56241.yaml b/releasenotes/notes/bug-2006334-0cd8f59073f56241.yaml new file mode 100644 index 0000000000..f6a4e151fb --- /dev/null +++ b/releasenotes/notes/bug-2006334-0cd8f59073f56241.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes an issue regarding the ``ansible`` deploy interface, where the + configdrive partition could not be correctly built if the node root + device was set to some logical device (like an md array, /dev/md0). + https://storyboard.openstack.org/#!/story/2006334