Protect against parallel exec of gen-bootloader-iso.sh
The bulk of the work done by gen-bootloader-iso.sh is not safe to be executed by two callers in parallel. If the initial execution is setting up shared files when a subsequent call starts, the subsequent call can end up with an incomplete set of symlinks to shared files. This, in turn, can result in installation failures. To protect against this, a file lock is added to gen-bootloader-iso.sh to prevent subsequent calls from accessing shared files before they're completely setup. Change-Id: Id6def4527b226b8746b2b8ff74059c0d3937e130 Closes-Bug: 1885779 Signed-off-by: Don Penney <don.penney@windriver.com>
This commit is contained in:
parent
a10381203d
commit
7ed511a6a0
|
@ -1,4 +1,4 @@
|
|||
SRC_DIR="platform-util"
|
||||
COPY_LIST_TO_TAR="scripts"
|
||||
|
||||
TIS_PATCH_VER=18
|
||||
TIS_PATCH_VER=PKG_GITREVCOUNT
|
||||
|
|
|
@ -36,6 +36,7 @@ declare DELETE="no"
|
|||
declare GRUB_TIMEOUT=-1
|
||||
declare INPUT_ISO=
|
||||
declare KS_NODETYPE=
|
||||
declare -i LOCK_TMOUT=600 # Wait up to 10 minutes, by default
|
||||
declare NODE_ID=
|
||||
declare ORIG_PWD=$PWD
|
||||
declare OUTPUT_ISO=
|
||||
|
@ -72,6 +73,7 @@ Optional parameters for setup:
|
|||
--boot-netmask <mask>: Specify netmask for boot interface
|
||||
--boot-gateway <addr>: Specify gateway for boot interface
|
||||
--timeout <seconds>: Specify boot menu timeout, in seconds
|
||||
--lock-timeout <secs>: Specify time to wait for mutex lock before aborting
|
||||
--param <p=v>: Specify boot parameter customization
|
||||
Examples:
|
||||
--param rootfs_device=nvme0n1 --param boot_device=nvme0n1
|
||||
|
@ -113,7 +115,7 @@ ENDUSAGE
|
|||
#
|
||||
# Parse cmdline arguments
|
||||
#
|
||||
LONGOPTS="input:,addon:,param:,default-boot:,timeout:"
|
||||
LONGOPTS="input:,addon:,param:,default-boot:,timeout:,lock-timeout:"
|
||||
LONGOPTS="${LONGOPTS},base-url:,www-root:,id:,delete"
|
||||
LONGOPTS="${LONGOPTS},boot-gateway:,boot-hostname:,boot-interface:,boot-ip:,boot-netmask:"
|
||||
LONGOPTS="${LONGOPTS},help"
|
||||
|
@ -228,6 +230,14 @@ while :; do
|
|||
NODE_ID=$2
|
||||
shift 2
|
||||
;;
|
||||
--lock-timeout)
|
||||
LOCK_TMOUT=$2
|
||||
shift 2
|
||||
if [ $LOCK_TMOUT -le 0 ]; then
|
||||
echo "Lock timeout must be greater than 0" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--delete)
|
||||
DELETE="yes"
|
||||
shift
|
||||
|
@ -511,6 +521,15 @@ if [ ! -d "${WWW_ROOT_DIR}" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Grab the lock, to protect against simultaneous execution
|
||||
LOCK_FILE=/var/run/.gen-bootloader-iso.lock
|
||||
exec 200>${LOCK_FILE}
|
||||
flock -w ${LOCK_TMOUT} 200
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "Failed waiting for lock: ${LOCK_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for deletion
|
||||
if [ ${DELETE} = "yes" ]; then
|
||||
handle_delete
|
||||
|
|
Loading…
Reference in New Issue