diff --git a/parts/common/components.json b/parts/common/components.json index e6cd79b0fb5..65de8e6f7ef 100644 --- a/parts/common/components.json +++ b/parts/common/components.json @@ -2219,7 +2219,7 @@ "versionsV2": [ { "renovateTag": "", - "latestVersion": "0.3.1" + "latestVersion": "1.0.0" } ], "downloadURL": "https://acrstreamingpackage.z5.web.core.windows.net/${version}/acr-mirror-2004.deb" @@ -2228,7 +2228,7 @@ "versionsV2": [ { "renovateTag": "", - "latestVersion": "0.3.1" + "latestVersion": "1.0.0" } ], "downloadURL": "https://acrstreamingpackage.z5.web.core.windows.net/${version}/acr-mirror-2204.deb" @@ -2237,7 +2237,7 @@ "versionsV2": [ { "renovateTag": "", - "latestVersion": "0.3.1" + "latestVersion": "1.0.0" } ], "downloadURL": "https://acrstreamingpackage.z5.web.core.windows.net/${version}/acr-mirror-2404.deb" @@ -2248,7 +2248,7 @@ "versionsV2": [ { "renovateTag": "", - "latestVersion": "0.3.1" + "latestVersion": "1.0.0" } ], "downloadURL": "https://acrstreamingpackage.z5.web.core.windows.net/${version}/acr-mirror-azurelinux3.rpm" diff --git a/parts/linux/cloud-init/artifacts/cse_config.sh b/parts/linux/cloud-init/artifacts/cse_config.sh index e73c6919d1a..025292aefe4 100755 --- a/parts/linux/cloud-init/artifacts/cse_config.sh +++ b/parts/linux/cloud-init/artifacts/cse_config.sh @@ -427,8 +427,16 @@ ensureNoDupOnPromiscuBridge() { ensureArtifactStreaming() { waitForContainerdReady || exit $ERR_ARTIFACT_STREAMING_INSTALL - retrycmd_if_failure 120 5 25 systemctl --quiet enable --now acr-mirror overlaybd-tcmu overlaybd-snapshotter - /opt/acr/bin/acr-config --enable-containerd 'azurecr.io' + retrycmd_if_failure 120 5 25 systemctl --quiet enable --now acr-mirror overlaybd-tcmu overlaybd-snapshotter || exit $ERR_ARTIFACT_STREAMING_INSTALL + + local acr_mirror_setup="${ACR_MIRROR_SETUP_SCRIPT:-/opt/acr/tools/mirror/setup.sh}" + if [ -x "$acr_mirror_setup" ]; then + "$acr_mirror_setup" aks + else + echo "Older acr-mirror package is detected, using old acr-config enablement" + # setup.sh is only available in acr-mirror 1.0.0 and above + "${ACR_CONFIG_BIN:-/opt/acr/bin/acr-config}" --enable-containerd 'azurecr.io' + fi } ensureDHCPv6() { diff --git a/spec/parts/linux/cloud-init/artifacts/cse_config_spec.sh b/spec/parts/linux/cloud-init/artifacts/cse_config_spec.sh index 6d8ee01e50a..b10d778fd94 100755 --- a/spec/parts/linux/cloud-init/artifacts/cse_config_spec.sh +++ b/spec/parts/linux/cloud-init/artifacts/cse_config_spec.sh @@ -74,6 +74,70 @@ Describe 'cse_config.sh' End End + Describe 'ensureArtifactStreaming' + # ensureArtifactStreaming enables the acr-mirror/overlaybd services and then + # runs the version-appropriate enablement path: + # - acr-mirror 1.0.0+ -> setup.sh aks + # - older packages -> acr-config --enable-containerd + # The enablement binary paths are overridable (ACR_MIRROR_SETUP_SCRIPT / + # ACR_CONFIG_BIN), so the stubs live in a temp dir instead of mutating /opt. + setup_streaming() { + TEST_ACR_DIR="$(mktemp -d)" + ACR_MIRROR_SETUP_SCRIPT="${TEST_ACR_DIR}/setup.sh" + ACR_CONFIG_BIN="${TEST_ACR_DIR}/acr-config" + } + cleanup_streaming() { + rm -rf "${TEST_ACR_DIR}" + } + BeforeEach 'setup_streaming' + AfterEach 'cleanup_streaming' + + waitForContainerdReady() { + return 0 + } + systemctl() { + echo "systemctl $@" + } + retrycmd_if_failure() { + echo "retrycmd_if_failure $@" + return "${RETRYCMD_RC:-0}" + } + + install_setup_sh() { + printf '#!/bin/sh\necho "setup.sh $@"\n' > "${ACR_MIRROR_SETUP_SCRIPT}" + chmod +x "${ACR_MIRROR_SETUP_SCRIPT}" + } + install_acr_config() { + printf '#!/bin/sh\necho "acr-config $@"\n' > "${ACR_CONFIG_BIN}" + chmod +x "${ACR_CONFIG_BIN}" + } + + It 'uses setup.sh aks when acr-mirror 1.0.0+ is installed' + install_setup_sh + When run ensureArtifactStreaming + The output should include "setup.sh aks" + The output should not include "Older acr-mirror package" + The status should be success + End + + It 'falls back to acr-config enablement when setup.sh is absent (older package)' + install_acr_config + When run ensureArtifactStreaming + The output should include "Older acr-mirror package is detected" + The output should include "acr-config --enable-containerd azurecr.io" + The status should be success + End + + It 'fails fast when enabling the streaming services fails' + RETRYCMD_RC=1 + install_setup_sh + When run ensureArtifactStreaming + The output should include "retrycmd_if_failure" + The output should not include "setup.sh aks" + The status should equal "$ERR_ARTIFACT_STREAMING_INSTALL" + End + End + Describe 'configureAzureJson' AZURE_JSON_PATH="azure.json" AKS_CUSTOM_CLOUD_JSON_PATH="customcloud.json" diff --git a/vhdbuilder/packer/install-dependencies.sh b/vhdbuilder/packer/install-dependencies.sh index 3762d1141c5..d286d2286fd 100644 --- a/vhdbuilder/packer/install-dependencies.sh +++ b/vhdbuilder/packer/install-dependencies.sh @@ -656,13 +656,6 @@ installAndConfigureArtifactStreaming() { rm "$MIRROR_DOWNLOAD_PATH" /opt/acr/tools/overlaybd/install.sh - /opt/acr/tools/overlaybd/config-user-agent.sh azure - /opt/acr/tools/overlaybd/enable-http-auth.sh - /opt/acr/tools/overlaybd/config.sh download.enable false - /opt/acr/tools/overlaybd/config.sh cacheConfig.cacheSizeGB 32 - /opt/acr/tools/overlaybd/config.sh exporterConfig.enable true - /opt/acr/tools/overlaybd/config.sh exporterConfig.port 9863 - systemctl link /opt/overlaybd/overlaybd-tcmu.service /opt/overlaybd/snapshotter/overlaybd-snapshotter.service # Remove the bundled overlaybd installer packages (~55-58 MB); install.sh already installed them and they're unused at runtime. rm -f /opt/acr/tools/overlaybd/bin/*.deb /opt/acr/tools/overlaybd/bin/*.rpm echo " - acr-mirror version ${version}" >> ${VHD_LOGS_FILEPATH}