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

perf: run installBcc in a subshell #4290

Merged
merged 10 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 24 additions & 5 deletions vhdbuilder/packer/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,17 @@ ls -ltr /opt/gpu/* >> ${VHD_LOGS_FILEPATH}
installBpftrace
echo " - $(bpftrace --version)" >> ${VHD_LOGS_FILEPATH}

installBcc
cat << EOF >> ${VHD_LOGS_FILEPATH}
- bcc-tools
- libbcc-examples
EOF
PRESENT_DIR=$(pwd)
# run installBcc in a subshell and continue on with container image pull in order to decrease total build time
(
cd $PRESENT_DIR || { echo "Subshell in the wrong directory" >&2; exit 1; }

installBcc

exit $?
) > /var/log/bcc_installation.log 2>&1 &

BCC_PID=$!

echo "${CONTAINER_RUNTIME} images pre-pulled:" >> ${VHD_LOGS_FILEPATH}
stop_watch $capture_time "Pull NVIDIA driver image (mcr), Start installBcc subshell" false
Expand Down Expand Up @@ -494,6 +500,19 @@ if [[ $OS == $UBUNTU_OS_NAME ]]; then
sed -i 's/After=network-online.target/After=multi-user.target/g' /lib/systemd/system/motd-news.service
fi

wait $BCC_PID
BCC_EXIT_CODE=$?

if [ $BCC_EXIT_CODE -eq 0 ]; then
echo "Bcc tools successfully installed."
cat << EOF >> ${VHD_LOGS_FILEPATH}
- bcc-tools
- libbcc-examples
EOF
else
echo "Error: installBcc subshell failed with exit code $BCC_EXIT_CODE" >&2
fi

# use the private_packages_url to download and cache packages
if [[ -n ${PRIVATE_PACKAGES_URL} ]]; then
IFS=',' read -ra PRIVATE_URLS <<< "${PRIVATE_PACKAGES_URL}"
Expand Down
11 changes: 11 additions & 0 deletions vhdbuilder/packer/test/linux-vhd-content-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,16 @@ testContainerImagePrefetchScript() {
return 0
}

testBccTools () {
for line in '- bcc-tools' '- libbcc-examples'; do
if ! grep -F -x -e "$line" /opt/azure/vhd-install.complete; then
echo "BCC tools were not successfully downloaded."
return 1
fi
done
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be simplified - just return 1 inside the then condition if line is missing

echo "BCC tools were successfully downloaded."
return 0
}

# As we call these tests, we need to bear in mind how the test results are processed by the
# the caller in run-tests.sh. That code uses az vm run-command invoke to run this script
Expand All @@ -867,6 +877,7 @@ testContainerImagePrefetchScript() {
#
# We should also avoid early exit from the test run -- like if a command fails with
# an exit rather than a return -- because that prevents other tests from running.
testBccTools
testVHDBuildLogsExist
testCriticalTools
testFilesDownloaded $CONTAINER_RUNTIME
Expand Down
Loading