Skip to content

Commit

Permalink
[ci] Fix and improve k8s master image build process (sonic-net#18157)
Browse files Browse the repository at this point in the history
Why I did it
When we change k8s script file to trigger k8s master image build, there's error reported.

/agent/_work/_temp/433f6aca-4fd0-4a79-898e-49d7d0fc7465.sh: line 19: unexpected EOF while looking for matching `''
The main reason is something wrong with passing k8s_options variable(in file template-skipvstest.yml) to build pipeline. Need to fix and improve the passing variable process.

Work item tracking
Microsoft ADO (number only): 25063800
How I did it
Separate the job of checking if k8s image build is needed from skipvstest checking job
Build a VHDX k8s master image for convenient
How to verify it
No error found when k8s master image build is triggered
We have a VHDX k8s master image in the build result.
  • Loading branch information
lixiaoyuner authored Mar 11, 2024
1 parent 9505f82 commit cd897b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 7 additions & 3 deletions .azure-pipelines/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ jobs:
make $BUILD_OPTIONS ENABLE_ASAN=y target/docker-sonic-vs.gz
mv target/docker-sonic-vs.gz target/docker-sonic-vs-asan.gz
fi
if [ "$(K8S_OPTIONS)" == 'INCLUDE_KUBERNETES_MASTER=y' ]; then
make $BUILD_OPTIONS $(K8S_OPTIONS) target/sonic-vs.img.gz
mv target/sonic-vs.img.gz target/sonic-vs-k8s.img.gz
if [ "$(K8S_MASTER_CHANGED)" == 'YES' ]; then
make $BUILD_OPTIONS INCLUDE_KUBERNETES_MASTER=y target/sonic-vs.img.gz
gzip -d target/sonic-vs.img.gz
SONIC_RUN_CMDS="qemu-img convert target/sonic-vs.img -O vhdx -o subformat=dynamic target/sonic-vs.vhdx" make $BUILD_OPTIONS sonic-slave-run
gzip target/sonic-vs.vhdx
mv target/sonic-vs.vhdx.gz target/sonic-vs-k8s.vhdx.gz
rm target/sonic-vs.img
fi
make $BUILD_OPTIONS target/docker-sonic-vs.gz target/sonic-vs.img.gz target/docker-ptf.gz
make $BUILD_OPTIONS target/docker-ptf-sai.gz
Expand Down
13 changes: 9 additions & 4 deletions .azure-pipelines/template-skipvstest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ steps:
set -ex
tar_branch=origin/$(System.PullRequest.TargetBranchName)
# Check if k8s master entrance script is changed
if ! git diff $tar_branch..HEAD --name-only | grep -F files/image_config/kubernetes/kubernetes_master_entrance.sh; then
echo "##vso[task.setvariable variable=K8S_OPTIONS;]INCLUDE_KUBERNETES_MASTER=n"
else
echo "##vso[task.setvariable variable=K8S_OPTIONS;]INCLUDE_KUBERNETES_MASTER=y"
K8S_MASTER_CHANGED=NO
if git diff $tar_branch..HEAD --name-only | grep -F files/image_config/kubernetes/kubernetes_master_entrance.sh; then
K8S_MASTER_CHANGED=YES
fi
set +x
echo "##vso[task.setvariable variable=K8S_MASTER_CHANGED;]$K8S_MASTER_CHANGED"
displayName: "Check if k8s master image build is needed."
- script: |
set -ex
tar_branch=origin/$(System.PullRequest.TargetBranchName)
git diff $tar_branch..HEAD --name-only | grep -v -f .azure-pipelines/vstest-exclude && exit 0
git diff $tar_branch..HEAD --name-only | grep -f .azure-pipelines/vstest-include && exit 0
set +x
Expand Down

0 comments on commit cd897b4

Please sign in to comment.