Skip to content

Commit

Permalink
[ci] Fix docker hang issue and change template reference branch (soni…
Browse files Browse the repository at this point in the history
…c-net#13894) (sonic-net#13921)

Why I did it
Cherry pick PR(sonic-net#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
  • Loading branch information
liushilongbuaa authored Feb 23, 2023
1 parent 0095ad5 commit b23f79f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .azure-pipelines/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ jobs:
platform_rpc: nephos

buildSteps:
- template: template-skipvstest.yml
- template: .azure-pipelines/template-skipvstest.yml@buildimage
- template: .azure-pipelines/template-daemon.yml@buildimage
- bash: |
(
while true
Expand Down Expand Up @@ -170,4 +171,4 @@ jobs:
fi
sudo kill $daemon_pid
displayName: "Build sonic image"
- template: check-dirty-version.yml
- template: .azure-pipelines/check-dirty-version.yml@buildimage
4 changes: 2 additions & 2 deletions .azure-pipelines/azure-pipelines-image-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
jobFilters: ${{ parameters.jobFilters }}
jobVariables: ${{ parameters.jobVariables }}
preSteps:
- template: cleanup.yml
- template: .azure-pipelines/cleanup.yml@buildimage
- ${{ parameters.preSteps }}
- script: |
if [ -n "$(CACHE_MODE)" ] && echo $(PLATFORM_AZP) | grep -E -q "^(vs|broadcom|mellanox|marvell-armhf)$"; then
Expand Down Expand Up @@ -67,6 +67,6 @@ jobs:
artifactName: 'sonic-buildimage.$(GROUP_NAME)$(GROUP_EXTNAME)'
publishPrefix: '$(Build.DefinitionName)/$(Build.SourceBranchName)/$(GROUP_NAME)'
- ${{ parameters.postSteps }}
- template: cleanup.yml
- template: .azure-pipelines/cleanup.yml@buildimage
jobGroups: ${{ parameters.jobGroups }}
buildSteps: ${{ parameters.buildSteps }}
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" " -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

0 comments on commit b23f79f

Please sign in to comment.