Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit d3f5a70

Browse files
sjsinjujkotas
authored andcommitted
ARM-CI : Check a device is already mounted while mounting a device. (#6377)
Now ARM-CI makes building failure frequently with below messages.(#6329) http://dotnet-ci.cloudapp.net/job/dotnet_coreclr/job/master/job/arm_emulator_cross_debug_ubuntu_prtest/559/console 00:01:27.252 + sudo umount /opt/linux-arm-emulator-root/dev 00:01:27.260 umount: /opt/linux-arm-emulator-root/dev: device is busy. 00:01:27.260 (In some cases useful info about processes that use 00:01:27.260 the device is found by lsof(8) or fuser(1)) 00:01:27.265 Build step 'Execute shell' marked build as failure I think ARM CI jobs have tried to unmount the same rootfs by an 'arm32_ci_script.sh' at the same time. (At this time, other jobs still are on running...) So I suggest though the script is exited by any cases, the script would not run un-mounting. But whenever CI is running and mounting a device, It will check the device is already mounted.
1 parent 9f74aff commit d3f5a70

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

tests/scripts/arm32_ci_script.sh

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -121,27 +121,11 @@ function clean_emulator {
121121
sudo rm -rf "$__ARMRootfsCoreclrPath" "$__ARMRootfsCorefxPath"
122122
}
123123

124-
#Unmount the emulator file systems
125-
function unmount_emulator {
126-
(set +x; echo 'Unmounting emulator...')
127-
128-
#Unmount all the mounted emulator file systems
129-
unmount_rootfs "$__ARMRootfsMountPath/proc"
130-
unmount_rootfs "$__ARMRootfsMountPath/dev/pts"
131-
unmount_rootfs "$__ARMRootfsMountPath/dev"
132-
unmount_rootfs "$__ARMRootfsMountPath/run/shm"
133-
unmount_rootfs "$__ARMRootfsMountPath/sys"
134-
unmount_rootfs "$__ARMRootfsMountPath"
135-
}
136-
137124
#Clean the changes made to the environment by the script
138125
function clean_env {
139126
#Clean the emulator
140127
clean_emulator
141128

142-
#Unmount the emulator
143-
unmount_emulator
144-
145129
#Check for revert of git changes
146130
check_git_head
147131
}
@@ -152,28 +136,50 @@ function handle_ctrl_c {
152136

153137
echo 'ERROR: Ctrl-C handled. Script aborted before complete execution.'
154138

155-
clean_env
156-
157139
exit 1
158140
}
159141
trap handle_ctrl_c INT
160142

143+
#Trap Exit and handle it
144+
function handle_exit {
145+
set +x
146+
147+
echo 'The script is exited. Cleaning environment..'
148+
149+
clean_env
150+
}
151+
trap handle_exit EXIT
152+
153+
154+
#Mount with checking to be already existed
155+
function mount_with_checking {
156+
set +x
157+
local options="$1"
158+
local from="$2"
159+
local rootfsFolder="$3"
160+
161+
if mountpoint -q -- "$rootfsFolder"; then
162+
(set +x; echo "$rootfsFolder is already mounted.")
163+
else {
164+
(set -x; sudo mount $options "$from" "$rootfsFolder")
165+
}
166+
fi
167+
}
168+
161169
#Mount emulator to the target mount path
162170
function mount_emulator {
163171
#Check if the mount path exists and create if neccessary
164172
if [ ! -d "$__ARMRootfsMountPath" ]; then
165173
sudo mkdir "$__ARMRootfsMountPath"
166174
fi
167175

168-
#Unmount the emulator if already mounted at the mount path and mount again
169-
unmount_emulator
170-
171-
sudo mount "$__ARMEmulPath"/platform/rootfs-t30.ext4 "$__ARMRootfsMountPath"
172-
sudo mount -t proc /proc "$__ARMRootfsMountPath"/proc
173-
sudo mount -o bind /dev/ "$__ARMRootfsMountPath"/dev
174-
sudo mount -o bind /dev/pts "$__ARMRootfsMountPath"/dev/pts
175-
sudo mount -t tmpfs shm "$__ARMRootfsMountPath"/run/shm
176-
sudo mount -o bind /sys "$__ARMRootfsMountPath"/sys
176+
set +x
177+
mount_with_checking "" "$__ARMEmulPath/platform/rootfs-t30.ext4" "$__ARMRootfsMountPath"
178+
mount_with_checking "-t proc" "/proc" "$__ARMRootfsMountPath/proc"
179+
mount_with_checking "-o bind" "/dev/" "$__ARMRootfsMountPath/dev"
180+
mount_with_checking "-o bind" "/dev/pts" "$__ARMRootfsMountPath/dev/pts"
181+
mount_with_checking "-t tmpfs" "shm" "$__ARMRootfsMountPath/run/shm"
182+
mount_with_checking "-o bind" "/sys" "$__ARMRootfsMountPath/sys"
177183
}
178184

179185
#Cross builds coreclr

0 commit comments

Comments
 (0)