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

fix: add support for 'cvm' image SKU in packer build process #5759

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions packer.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ ifeq (${OS_SKU},Ubuntu)
ifeq (${IMG_SKU},20_04-lts-cvm)
@echo "Using packer template file vhd-image-builder-cvm.json"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-cvm.json
else ifeq (${IMG_SKU},cvm)
@echo "Using packer template file vhd-image-builder-cvm.json"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-cvm.json
else
@echo "Using packer template file vhd-image-builder-base.json"
@packer build -var-file=vhdbuilder/packer/settings.json vhdbuilder/packer/vhd-image-builder-base.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if [[ ${OS_TYPE} == "Linux" && ${ENABLE_TRUSTED_LAUNCH} == "True" ]]; then
} \
} \
}"
elif [ "${OS_TYPE}" == "Linux" ] && [ "${IMG_SKU,,}" == "20_04-lts-cvm" ]; then
elif [ "${OS_TYPE}" == "Linux" ] && [[ "${IMG_SKU}" == "20_04-lts-cvm" || "${IMG_SKU}" == "cvm" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does IMG_SKU='cvm' specifically imply 2404cvm? If that's the case, is there any reason why it's not named as 24_04-lts-cvm. I could be wrong, but from the naming it seems 'cvm' includes all SKUs ranging from 18.04 to 24.04 CVM.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IMG_SKU is defined by ubuntu version. Currently the only sku that has img_sku == cvm is 2404.

But if the sku is CVM regardless of version it should need special cvm build that should be caught by this if sku==cvm

az resource create --id $disk_resource_id --is-full-object --location $LOCATION --properties "{\"location\": \"$LOCATION\", \
\"properties\": { \
\"osType\": \"$OS_TYPE\", \
Expand Down
16 changes: 8 additions & 8 deletions vhdbuilder/packer/init-variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if [ "$MODE" == "linuxVhdMode" ] && [ -z "${PACKER_BUILD_LOCATION}" ]; then
exit 1
fi

if [ "${IMG_SKU,,}" == "20_04-lts-cvm" ] && [ -n "${CVM_PACKER_BUILD_LOCATION}" ]; then
if [[ "${IMG_SKU,,}" == "20_04-lts-cvm" || "${IMG_SKU,,}" == "cvm" ]] && [ -n "${CVM_PACKER_BUILD_LOCATION}" ]; then
PACKER_BUILD_LOCATION="${CVM_PACKER_BUILD_LOCATION}"
echo "CVM: PACKER_BUILD_LOCATION is set to ${PACKER_BUILD_LOCATION}"
fi
Expand Down Expand Up @@ -172,8 +172,8 @@ if [[ "${MODE}" == "linuxVhdMode" ]]; then
elif [[ "${IMG_OFFER,,}" == "azure-linux-3" ]]; then
# for Azure Linux 3.0, only use AzureLinux prefix
SIG_IMAGE_NAME="AzureLinux${SIG_IMAGE_NAME}"
elif [[ "${IMG_SKU,,}" == "20_04-lts-cvm" ]]; then
SIG_IMAGE_NAME+="Specialized"
elif [[ "${IMG_SKU,,}" == "20_04-lts-cvm" || "${IMG_SKU,,}" == "cvm" ]]; then
SIG_IMAGE_NAME+="Specialized"
fi
echo "No input for SIG_IMAGE_NAME was provided, defaulting to: ${SIG_IMAGE_NAME}"
else
Expand Down Expand Up @@ -261,13 +261,13 @@ if [[ "$MODE" == "linuxVhdMode" || "$MODE" == "windowsVhdMode" ]]; then
if [ -z "$id" ]; then
echo "Creating image definition ${SIG_IMAGE_NAME} in gallery ${SIG_GALLERY_NAME} resource group ${AZURE_RESOURCE_GROUP_NAME}"
# The following conditionals do not require NVMe tagging on disk controller type
if [[ ${ARCHITECTURE,,} == "arm64" ]] || [[ ${IMG_SKU} == "20_04-lts-cvm" ]] || [[ ${HYPERV_GENERATION} == "V1" ]]; then
if [[ ${ARCHITECTURE,,} == "arm64" ]] || [[ ${IMG_SKU} == "20_04-lts-cvm" ]] || [[ ${IMG_SKU} == "cvm" ]] || [[ ${HYPERV_GENERATION} == "V1" ]]; then
TARGET_COMMAND_STRING=""
if [[ ${ARCHITECTURE,,} == "arm64" ]]; then
TARGET_COMMAND_STRING+="--architecture Arm64"
elif [[ ${IMG_SKU} == "20_04-lts-cvm" ]]; then
TARGET_COMMAND_STRING+="--os-state Specialized --features SecurityType=ConfidentialVM"
fi
TARGET_COMMAND_STRING+="--architecture Arm64"
elif [[ ${IMG_SKU} == "20_04-lts-cvm" ]] || [[ ${IMG_SKU} == "cvm" ]]; then
TARGET_COMMAND_STRING+="--os-state Specialized --features SecurityType=ConfidentialVM"
fi

az sig image-definition create \
--resource-group ${AZURE_RESOURCE_GROUP_NAME} \
Expand Down
2 changes: 1 addition & 1 deletion vhdbuilder/packer/test/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if [ "${OS_TYPE}" == "Linux" ] && [ "${ENABLE_TRUSTED_LAUNCH}" == "True" ]; then
TARGET_COMMAND_STRING+="--security-type TrustedLaunch --enable-secure-boot true --enable-vtpm true"
fi

if [ "${OS_TYPE}" == "Linux" ] && [ ${IMG_SKU} == "20_04-lts-cvm" ]; then
if [ "${OS_TYPE}" == "Linux" ] && [[ "${IMG_SKU}" == "20_04-lts-cvm" || "${IMG_SKU}" == "cvm" ]]; then
# We completely re-assign the TARGET_COMMAND_STRING string here to ensure that no artifacts from earlier conditionals are included
TARGET_COMMAND_STRING="--size Standard_DC8ads_v5 --security-type ConfidentialVM --enable-secure-boot true --enable-vtpm true --os-disk-security-encryption-type VMGuestStateOnly --specialized true"
fi
Expand Down
2 changes: 1 addition & 1 deletion vhdbuilder/packer/vhd-scanning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if [[ "${OS_TYPE}" == "Linux" && "${ENABLE_TRUSTED_LAUNCH}" == "True" ]]; then
VM_OPTIONS+=" --security-type TrustedLaunch --enable-secure-boot true --enable-vtpm true"
fi

if [ "${OS_TYPE}" == "Linux" ] && [ ${IMG_SKU} == "20_04-lts-cvm" ]; then
if [ "${OS_TYPE}" == "Linux" ] && [[ "${IMG_SKU}" == "20_04-lts-cvm" || "${IMG_SKU}" == "cvm" ]]; then
# We completely re-assign the VM_OPTIONS string here to ensure that no artifacts from earlier conditionals are included
VM_OPTIONS="--size Standard_DC8ads_v5 --security-type ConfidentialVM --enable-secure-boot true --enable-vtpm true --os-disk-security-encryption-type VMGuestStateOnly --specialized true"
fi
Expand Down
Loading