Skip to content

Commit 02d605d

Browse files
[build] Refine docker build hanging and dpkg install hanging. (#24139)
Why I did it In some cases builds maybe stuck. Some hangs on docker build and some hangs on dpkg install. Work item tracking Microsoft ADO (number only): 35240457 How I did it Update pipeline daemon step to avoid docker build stuck. Add retry limit when dpkg install. signed-off-by: [email protected]
1 parent fd64bf8 commit 02d605d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

.azure-pipelines/template-daemon.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ steps:
55
do
66
sleep 120
77
now=$(date +%s)
8-
pids=$(ps -C docker-buildx -o pid,etime,args | grep "docker-buildx buildx build" | cut -d" " -f2)
8+
pids=$(ps -C docker-buildx -o pid,etime,args | grep "docker-buildx buildx build" | awk '{print $1}')
99
for pid in $pids
1010
do
11-
start=$(date --date="$(ls -dl /proc/$pid --time-style full-iso | awk '{print$6,$7}')" +%s)
12-
time_s=$(($now-$start))
13-
if [[ $time_s -gt $(DOCKER_BUILD_TIMEOUT) ]]; then
11+
start_ticks=$(awk '{print $22}' /proc/$pid/stat)
12+
boot_time=$(awk '/btime/ {print $2}' /proc/stat)
13+
hertz=$(getconf CLK_TCK)
14+
start_time=$((boot_time + start_ticks / hertz))
15+
ts=$(date -d "@$((now - start_time))" +%s)
16+
17+
if [[ $ts -gt $(DOCKER_BUILD_TIMEOUT) ]]; then
1418
echo =========== $(date +%F%T) $time_s &>> target/daemon.log
15-
ps $pid &>> target/daemon.log
19+
ps -p $pid -o pid,etime,args ww &>> target/daemon.log
1620
sudo kill $pid
1721
fi
1822
done

slave.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ SONIC_INSTALL_DEBS = $(addsuffix -install,$(addprefix $(DEBS_PATH)/, \
866866
$(SONIC_INSTALL_DEBS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) $(DEBS_PATH)/$$*
867867
$(HEADER)
868868
[ -f $(DEBS_PATH)/$* ] || { echo $(DEBS_PATH)/$* does not exist $(LOG) && false $(LOG) }
869-
while true; do
869+
for i in {1..360}; do
870870
# wait for conflicted packages to be uninstalled
871871
$(foreach deb, $($*_CONFLICT_DEBS), \
872872
{ while dpkg -s $(firstword $(subst _, ,$(basename $(deb)))) | grep "^Version: $(word 2, $(subst _, ,$(basename $(deb))))" &> /dev/null; do echo "waiting for $(deb) to be uninstalled" $(LOG); sleep 1; done } )

0 commit comments

Comments
 (0)