diff --git a/vhdbuilder/packer/configure-windows-vhd.ps1 b/vhdbuilder/packer/configure-windows-vhd.ps1 index e14062390a3..2b0efd92f66 100644 --- a/vhdbuilder/packer/configure-windows-vhd.ps1 +++ b/vhdbuilder/packer/configure-windows-vhd.ps1 @@ -205,6 +205,19 @@ function Get-FilesToCacheOnVHD { } } +function Get-ToolsToVHD { + # Rely on the completion of Get-FilesToCacheOnVHD + $cacheDir = "c:\akse-cache\tools" + + $toolsDir = "c:\aks-tools" + if (!(Test-Path -Path $toolsDir)) { + New-Item -ItemType Directory -Path $toolsDir | Out-Null + } + + Write-Log "Getting DU (Windows Disk Usage)" + Expand-Archive -Path "$cacheDir\DU.zip" -DestinationPath "$toolsDir\DU" -Force +} + function Get-PrivatePackagesToCacheOnVHD { if (![string]::IsNullOrEmpty($env:WindowsPrivatePackagesURL)) { Write-Log "Caching private packages on VHD" @@ -813,6 +826,7 @@ try{ Update-Registry Get-ContainerImages Get-FilesToCacheOnVHD + Get-ToolsToVHD # Rely on the completion of Get-FilesToCacheOnVHD Get-PrivatePackagesToCacheOnVHD Remove-Item -Path c:\windows-vhd-configuration.ps1 (New-Guid).Guid | Out-File -FilePath 'c:\vhd-id.txt' diff --git a/vhdbuilder/packer/generate-windows-vhd-configuration.ps1 b/vhdbuilder/packer/generate-windows-vhd-configuration.ps1 index e101972faef..8884eda88ef 100644 --- a/vhdbuilder/packer/generate-windows-vhd-configuration.ps1 +++ b/vhdbuilder/packer/generate-windows-vhd-configuration.ps1 @@ -177,6 +177,9 @@ $global:map = @{ "c:\akse-cache\calico\" = @( "https://acs-mirror.azureedge.net/calico-node/v3.21.6/binaries/calico-windows-v3.21.6.zip", "https://acs-mirror.azureedge.net/calico-node/v3.24.0/binaries/calico-windows-v3.24.0.zip" + ); + "c:\akse-cache\tools\" = @( + "https://download.sysinternals.com/files/DU.zip" ) } '@ diff --git a/vhdbuilder/packer/test/windows-vhd-content-test.ps1 b/vhdbuilder/packer/test/windows-vhd-content-test.ps1 index 68698d52bc9..6f93521a5a7 100644 --- a/vhdbuilder/packer/test/windows-vhd-content-test.ps1 +++ b/vhdbuilder/packer/test/windows-vhd-content-test.ps1 @@ -506,6 +506,19 @@ function Test-WindowsDefenderPlatformUpdate { } } +function Test-ToolsToCacheOnVHD { + $toolsDir = "c:\aks-tools" + $toolsList = @("DU\du.exe", "DU\du64.exe", "DU\du64a.exe") + + foreach ($tool in $toolsList) { + $toolPath = Join-Path -Path $toolsDir -ChildPath $tool + if (!(Test-Path -Path $toolPath)) { + Write-ErrorWithTimestamp "Failed to get tool: $toolPath" + exit 1 + } + } +} + Test-FilesToCacheOnVHD Test-PatchInstalled Test-ImagesPulled @@ -514,4 +527,5 @@ Test-DefenderSignature Test-AzureExtensions Test-ExcludeUDPSourcePort Test-WindowsDefenderPlatformUpdate +Test-ToolsToCacheOnVHD Remove-Item -Path c:\windows-vhd-configuration.ps1