sonic-buildimage/.azure-pipelines/template-daemon.yml
Liu Shilong b23f79f463
[ci] Fix docker hang issue and change template reference branch (#13894) (#13921)
Why I did it
Cherry pick PR(#13894)
Azure pipeline change.
Use common template to make it easy to change common steps. Fix docker hang issue.

How I did it
How to verify
2023-02-23 14:19:56 +08:00

25 lines
736 B
YAML

steps:
- bash: |
(
while true
do
sleep 120
now=$(date +%s)
pids=$(ps -C docker -o pid,etime,args | grep "docker build" | cut -d" " -f2)
for pid in $pids
do
start=$(date --date="$(ls -dl /proc/$pid --time-style full-iso | awk '{print$6,$7}')" +%s)
time_s=$(($now-$start))
if [[ $time_s -gt $(DOCKER_BUILD_TIMEOUT) ]]; then
echo =========== $(date +%F%T) $time_s &>> target/daemon.log
ps $pid &>> target/daemon.log
sudo kill $pid
fi
done
done
) &
daemon_pid=$!
ps $daemon_pid
echo $daemon_pid >> /tmp/azp_daemon_kill_docker_pid
displayName: start daemon to kill hang docker