Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] Kill hanged docker build process to avoid build timeout issue. #13726

Merged
merged 11 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .azure-pipelines/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ jobs:

buildSteps:
- template: template-skipvstest.yml
- template: template-daemon.yml
- bash: |
set -ex
if [ $(GROUP_NAME) == vs ]; then
Expand Down Expand Up @@ -168,4 +169,5 @@ jobs:
make $BUILD_OPTIONS target/sonic-$(GROUP_NAME).bin
fi
displayName: "Build sonic image"
- template: template-stop-daemon.yml
- template: check-dirty-version.yml
24 changes: 24 additions & 0 deletions .azure-pipelines/template-daemon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
steps:
- bash: |
(
while true
do
sleep 120
now=$(date +%s)
pids=$(ps -C docker -o pid,etime,args | grep "docker build" | cut -d" " -f1)
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 "##vso[task.setvariable variable=DAEMON_PID]$daemon_pid"
liushilongbuaa marked this conversation as resolved.
Show resolved Hide resolved
displayName: start daemon to kill hang docker
5 changes: 5 additions & 0 deletions .azure-pipelines/template-stop-daemon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
steps:
- bash: |
liushilongbuaa marked this conversation as resolved.
Show resolved Hide resolved
ps $(DAEMON_PID)
sudo kill $(DAEMON_PID) || true
displayName: kill daemon process
liushilongbuaa marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions .azure-pipelines/template-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ variables:
SONIC_BUILD_RETRY_COUNT: 3
SONIC_BUILD_RETRY_INTERVAL: 600
DOCKER_BUILDKIT: 0
DOCKER_BUILD_TIMEOUT: 3600