B&R: Skip Ceph osds from getting wiped during initial installation

To keep ceph-mon data intact at restore, ceph osds should not be wiped.
Every ceph osd has a Globally unique identifier(GUID) and based on this
GUID ceph osds are not added in list of devices to wipe.
Since installation is the same on restore as on a fresh install we need
to keep ceph data intact then delegate the wipe to ansible if we are not
at restore (or we are at restore but user does not want to keep ceph's
data). To keep the previous behavior, when any other node is installed
we wipe Ceph.

Story: 2004761
Task: 34283
Change-Id: Ief93da56c1344ab259e674ca8d79f9952fefcd2b
Signed-off-by: Elena Taivan <elena.taivan@windriver.com>
This commit is contained in:
Elena Taivan 2019-05-29 13:42:13 +00:00 committed by Ovidiu Poncea
parent c8603da349
commit 1834d0aeeb

View File

@ -66,6 +66,16 @@ fi
# Deactivate existing volume groups to avoid Anaconda issues with pre-existing groups
vgs --noheadings -o vg_name | xargs --no-run-if-empty -n 1 vgchange -an
# Check if active controller is available
curl -sf http://pxecontroller:6385/v1 2>&1 >/dev/null
if [ $? -eq 0 ]; then
echo "Active controller detected."
ACTIVE_EXISTS="true"
else
echo "No active controller detected, this is the initial install."
ACTIVE_EXISTS="false"
fi
ONLYUSE_HDD=""
if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/$(hostname)/in_upgrade 2>/dev/null)" = "true" ]; then
# In an upgrade, only wipe the disk with the rootfs and boot partition
@ -79,6 +89,10 @@ if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/$(hostname)/in_upgrade 2>/
else
# Make a list of all the hard drives that are to be wiped
WIPE_HDD=""
# Partition type OSD has a unique globally identifier
part_type_guid_str="Partition GUID code"
CEPH_OSD_GUID="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
for f in /dev/disk/by-path/*
do
dev=$(readlink -f $f)
@ -91,16 +105,37 @@ else
# Avoid wiping USB drives
udevadm info --query=property --name=$dev |grep -q '^ID_BUS=usb' && continue
# Avoid wiping ceph osds on initial install
if [ ${ACTIVE_EXISTS} == "false" ]; then
wipe_dev="true"
part_numbers=( `parted -s $dev print | awk '$1 == "Number" {i=1; next}; i {print $1}'` )
# Scanning the partitions looking for CEPH OSDs and
# skipping any disk found with such partitions
for part_number in "${part_numbers[@]}"; do
sgdisk_part_info=$(flock $dev sgdisk -i $part_number $dev)
part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
if [ "$part_type_guid" == $CEPH_OSD_GUID ]; then
echo "OSD found on $dev, skipping wipe"
wipe_dev="false"
break
fi
done
if [ "$wipe_dev" == "false" ]; then
continue
fi
fi
# Add device to the wipe list
devname=$(basename $dev)
if [ -e $dev -a "$ISO_DEV" != "../../$devname" -a "$USB_DEV" != "../../$devname" ] ; then
if [ -n "$WIPE_HDD" ] ; then
if [ -e $dev -a "$ISO_DEV" != "../../$devname" -a "$USB_DEV" != "../../$devname" ]; then
if [ -n "$WIPE_HDD" ]; then
WIPE_HDD=$WIPE_HDD,$dev
else
WIPE_HDD=$dev
fi
fi
done
echo "Not in upgrade, wiping all disks: $WIPE_HDD"
echo "Not in upgrade, wiping disks: $WIPE_HDD"
fi
for dev in ${WIPE_HDD//,/ }