Skip to content

Commit

Permalink
chore: replace endpoint in Mooncake
Browse files Browse the repository at this point in the history
  • Loading branch information
AbelHu committed Feb 26, 2025
1 parent 875c0b0 commit 03e3c74
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions vhdbuilder/packer/test/linux-vhd-content-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ testPackagesInstalled() {
echo $test "[INFO] File ${downloadedPackage} exists and has the correct size ${fileSizeDownloaded} bytes"
# Validate whether package exists in Azure China cloud
if [[ $downloadURL == https://acs-mirror.azureedge.net/* ]]; then
mcURL="${downloadURL/https:\/\/acs-mirror.azureedge.net/https:\/\/kubernetesartifacts.blob.core.chinacloudapi.cn}"
mcURL="${downloadURL/https:\/\/acs-mirror.azureedge.net/https:\/\/mirror.azk8s.cn}"
echo "Validating: $mcURL"
isExist=$(curl -sLI "$mcURL" | grep -i "404 The specified blob does not exist." | awk '{print $2}')
if [[ "$isExist" == "404" ]]; then
err "$mcURL is invalid"
continue
fi

fileSizeInMC=$(curl -sLI $mcURL | grep -i Content-Length | tail -n1 | awk '{print $2}' | tr -d '\r')
fileSizeInMC=$(wget -S $mcURL --start-pos=500G 2>&1 | grep -i Content-Length | tail -n1 | awk '{print $2}' | tr -d '\r')
if [[ "$fileSizeInMC" != "$fileSizeDownloaded" ]]; then
err "$mcURL is valid but the file size is different. Expected file size: ${fileSizeDownloaded} - downloaded file size: ${fileSizeInMC}"
continue
Expand Down
11 changes: 8 additions & 3 deletions vhdbuilder/packer/test/windows-files-check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,14 @@ function Test-CompareSingleDir {
}

if ($URL.StartsWith("https://acs-mirror.azureedge.net/")) {
$mcURL = $URL.replace("https://acs-mirror.azureedge.net/", "https://kubernetesartifacts.blob.core.chinacloudapi.cn/")

$mooncakeFileSize = (Invoke-WebRequest $mcURL -UseBasicParsing -Method Head).Headers.'Content-Length'
$mcURL = $URL.replace("https://acs-mirror.azureedge.net/", "https://mirror.azk8s.cn/")

$webRequest = [System.Net.HttpWebRequest]::Create($mcURL)
# Set the 'Range' header using the AddRange method
$webRequest.AddRange(0, 1023)
# Get the response
$response = $webRequest.GetResponse()
$mooncakeFileSize = $response.Headers["Content-Range"] -split "/" | Select-Object -Last 1

if ($globalFileSize -ne $mooncakeFileSize) {
$MisMatchFiles[$URL]=$mcURL
Expand Down
10 changes: 8 additions & 2 deletions vhdbuilder/packer/test/windows-vhd-content-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,18 @@ function Test-FilesToCacheOnVHD

if ( $URL.StartsWith("https://acs-mirror.azureedge.net/"))
{
$mcURL = $URL.replace("https://acs-mirror.azureedge.net/", "https://kubernetesartifacts.blob.core.chinacloudapi.cn/")
$mcURL = $URL.replace("https://acs-mirror.azureedge.net/", "https://mirror.azk8s.cn/")
try
{
# It's too slow to download the file from the China Cloud. So we only compare the file size.
$localFileSize = (Get-Item $dest).length
$remoteFileSize = (Invoke-WebRequest $mcURL -UseBasicParsing -Method Head).Headers.'Content-Length'

$webRequest = [System.Net.HttpWebRequest]::Create($mcURL)
# Set the 'Range' header using the AddRange method
$webRequest.AddRange(0, 1023)
# Get the response
$response = $webRequest.GetResponse()
$remoteFileSize = $response.Headers["Content-Range"] -split "/" | Select-Object -Last 1
if ($localFileSize -ne $remoteFileSize)
{
$isIgnore = $False
Expand Down

0 comments on commit 03e3c74

Please sign in to comment.