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 1 commit
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
20 changes: 20 additions & 0 deletions .azure-pipelines/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,25 @@ jobs:
buildSteps:
- template: template-skipvstest.yml
- bash: |
(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the step in a template, and the release branch use the same template?

while true
do
sleep 120
now=$(date +%s)
pids=$(ps aux | grep -v grep | grep -E "^.{,100}docker build" | awk '{print$2}')
Copy link
Collaborator

@xumia xumia Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to list the docker PIDs, right? A small improvement.
ps -C docker -o pid,etime,args | grep "docker build"
for line in lines:
do something

And etime can be used, not necessary to print the time again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 'ps -C' is good. But etime is not good to use.
etime has a format '[[dd-]hh:]mm:ss'. If I want to compare it with 1 hour, I need to compare the etime length.

for pid in $pids
do
start=$(date --date="$(ls -dl /proc/$pid --time-style full-iso | awk '{print$6,$7}')" +%s)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ps -o "lstart" $pid

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=$!
set -ex
if [ $(GROUP_NAME) == vs ]; then
if [ $(dbg_image) == yes ]; then
Expand Down Expand Up @@ -167,5 +186,6 @@ jobs:
fi
make $BUILD_OPTIONS target/sonic-$(GROUP_NAME).bin
fi
sudo kill $daemon_pid
displayName: "Build sonic image"
- template: check-dirty-version.yml
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