
Whenever a dev node that is not in use is opened with open(O_RDWR)
udev triggers a flush in devtmpfs that briefly remove & recreate all
the nodes for partitions on that device. This leads to commands
accessing dev nodes during the flush to fail. In our case blkid and
lsblk failed.
These failures are hard to reproduce, have devastating effect on
the partitioning operations and are not solved by using 'udevadm settle'
as some of the kernel events are asynchronous.
So, mainly, this commit stops udev from messing up with /dev nodes by
initializing file descriptors for all storage devices then opening
locks on them with flock. Setting locks stops udev triggering kernel
partition rescan.
Locks are set at the start of the partitioning operation and
released at the end.
For more details and similar cases see:
o 02ba8fb335
o http://tracker.ceph.com/issues/14080
o http://tracker.ceph.com/issues/15176
This commit:
o stops udev messing up with /dev nodes;
o aborts install on critical failures;
o adds retry for critical operations such as LVM cleanup or
partition removal and creation.
Closes-Bug: 1888938
Change-Id: Iaaaaaae973ee36f2c4bfd42c327e8c6278d59303
Signed-off-by: Ovidiu Poncea <ovidiu.poncea@windriver.com>
117 lines
5.6 KiB
INI
Executable File
117 lines
5.6 KiB
INI
Executable File
|
|
## NOTE: updates to partition sizes need to be also reflected in
|
|
## _controller_filesystem_limits() in sysinv/api/controllers/v1/istorconfig.py
|
|
|
|
ROOTFS_SIZE=20000
|
|
LOG_VOL_SIZE=8000
|
|
SCRATCH_VOL_SIZE=16000
|
|
PLATFORM_BACKUP_SIZE=10000
|
|
BOOT_SIZE=500
|
|
EFI_SIZE=300
|
|
|
|
ROOTFS_OPTIONS="defaults"
|
|
profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
|
|
if [ -n "$profile_mode" ]; then
|
|
# Enable iversion labelling for rootfs when IMA is enabled
|
|
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
|
fi
|
|
|
|
if [ -d /sys/firmware/efi ] ; then
|
|
BACKUP_PART=${ROOTFS_PART_PREFIX}1
|
|
BACKUP_PART_NO=1
|
|
START_POINT=1
|
|
END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE))
|
|
BACKUP_END_POINT=$END_POINT
|
|
if [ $BACKUP_CREATED -eq 0 ] ; then
|
|
wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
|
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
|
fi
|
|
|
|
START_POINT=$END_POINT
|
|
END_POINT=$(($START_POINT + $EFI_SIZE))
|
|
wlog "Creating EFI partition of ${EFI_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
|
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary fat32 ${START_POINT}MiB ${END_POINT}MiB"
|
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
|
|
|
cat<<EOF>>/tmp/part-include
|
|
part /boot/efi --fstype=efi --onpart=${ROOTFS_PART_PREFIX}2
|
|
EOF
|
|
else
|
|
BACKUP_PART=${ROOTFS_PART_PREFIX}2
|
|
BACKUP_PART_NO=2
|
|
wlog "Creating 1MB BIOS GRUB partition from 1MiB to 2MiB."
|
|
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary 1MiB 2MiB"
|
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
|
|
|
START_POINT=2
|
|
END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE))
|
|
BACKUP_END_POINT=$END_POINT
|
|
if [ $BACKUP_CREATED -eq 0 ] ; then
|
|
wlog "Creating platform backup partition of ${PLATFORM_BACKUP_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
|
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
|
fi
|
|
cat<<EOF>>/tmp/part-include
|
|
part biosboot --asprimary --fstype=biosboot --onpart=${ROOTFS_PART_PREFIX}1
|
|
EOF
|
|
fi
|
|
|
|
START_POINT=$END_POINT
|
|
END_POINT=$(($START_POINT + $BOOT_SIZE))
|
|
wlog "Creating boot partition of ${BOOT_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
|
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
|
|
|
START_POINT=$END_POINT
|
|
END_POINT=$(($START_POINT + $ROOTFS_SIZE))
|
|
wlog "Creating rootfs partition of ${ROOTFS_SIZE}MiB from ${START_POINT}MiB to ${END_POINT}MiB."
|
|
exec_retry 5 0.5 "parted -s $rootfs_device mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB"
|
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
|
|
|
START_POINT=$END_POINT
|
|
wlog "Creating cgcs-vg partition of ${CGCS_PV_SIZE}MiB from ${START_POINT}MiB to 100%."
|
|
exec_retry 5 0.5 "parted -s $rootfs_device mkpart extended ${START_POINT}MiB 100%"
|
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Partition creation failed!"
|
|
|
|
if [ $BACKUP_CREATED -ne 0 ] ; then
|
|
BACKUP_CURRENT_SIZE=$(parted -s $BACKUP_PART unit MiB print | grep $BACKUP_PART | awk '{print $3}' | sed 's/[^C0-9]*//g')
|
|
if [ $BACKUP_CURRENT_SIZE -lt $PLATFORM_BACKUP_SIZE ] ; then
|
|
wlog "Backup partition size is ${BACKUP_CURRENT_SIZE}MiB, resizing to ${PLATFORM_BACKUP_SIZE}MiB."
|
|
# parted will throw an error about overlapping with the next partition if we don't do this
|
|
BACKUP_END_POINT=$(($BACKUP_END_POINT - 1)).9
|
|
exec_retry 5 0.5 "parted -s $rootfs_device resizepart $BACKUP_PART_NO ${BACKUP_END_POINT}MiB"
|
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: resize of platform backup partition failed!"
|
|
exec_retry 2 0.1 "e2fsck -p -f $BACKUP_PART"
|
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: e2fsck failed on platform backup partition!"
|
|
exec_retry 2 1 "resize2fs $BACKUP_PART"
|
|
[ $? -ne 0 ] && report_pre_failure_with_msg "ERROR: Filed to resize ext4 fs of platform backup partition!"
|
|
elif [ $BACKUP_CURRENT_SIZE -gt $PLATFORM_BACKUP_SIZE ] ; then
|
|
report_pre_failure_with_msg "ERROR: Backup partition is ${BACKUP_CURRENT_SIZE}MiB expected size is less or equal to ${PLATFORM_BACKUP_SIZE}MiB."
|
|
else
|
|
wlog "Backup partition size is correct: ${PLATFORM_BACKUP_SIZE}MiB."
|
|
fi
|
|
cat<<EOF>>/tmp/part-include
|
|
part /opt/platform-backup --fstype=ext4 --asprimary --noformat --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS"
|
|
EOF
|
|
else
|
|
cat<<EOF>/tmp/backup-guid-change.sh
|
|
echo "\$(date '+%Y-%m-%d %H:%M:%S.%3N') - Updating backup partition GUID."
|
|
flock $rootfs_device sgdisk --change-name=${BACKUP_PART_NO}:"${BACKUP_PART_LABEL}" --typecode=${BACKUP_PART_NO}:"${BACKUP_PART_GUID}" $rootfs_device || exit 1
|
|
EOF
|
|
|
|
cat<<EOF>>/tmp/part-include
|
|
part /opt/platform-backup --fstype=ext4 --asprimary --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS"
|
|
EOF
|
|
fi
|
|
|
|
cat<<EOF>>/tmp/part-include
|
|
part /boot --fstype=ext4 --asprimary --onpart=${ROOTFS_PART_PREFIX}3 --fsoptions="$ROOTFS_OPTIONS"
|
|
part pv.253004 --onpart=${ROOTFS_PART_PREFIX}5
|
|
volgroup cgts-vg --pesize=32768 pv.253004
|
|
logvol /var/log --fstype=ext4 --vgname=cgts-vg --size=$LOG_VOL_SIZE --name=log-lv
|
|
logvol /scratch --fstype=ext4 --vgname=cgts-vg --size=$SCRATCH_VOL_SIZE --name=scratch-lv
|
|
part / --fstype=ext4 --asprimary --onpart=${ROOTFS_PART_PREFIX}4 --fsoptions="$ROOTFS_OPTIONS"
|
|
EOF
|
|
|