From f698b0e8bef4e80b1f70181054e8270a74f5d0f5 Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Thu, 15 Jul 2021 13:47:58 -0700 Subject: [PATCH] Change VM size to Standard_D32ds_v4. For some reason they are cheaper than D16 right now??? (#18953) Remove no longer used "unstable" scaffolding. Use ephemeral OS disks for better latency. Add ability to change whether temp disks are used or explicitly provisioned disks are used; explicitly provisioned disks turned out to be more expensive than expected before. Disable Windows Updates in the scale set because the machines are very short lived; working on a mechanism of patching the images instead. --- scripts/azure-pipelines/azure-pipelines.yml | 4 +- scripts/azure-pipelines/linux/create-vmss.ps1 | 58 ++++++++++++------ .../azure-pipelines/windows/create-vmss.ps1 | 59 ++++++++++--------- 3 files changed, 72 insertions(+), 49 deletions(-) diff --git a/scripts/azure-pipelines/azure-pipelines.yml b/scripts/azure-pipelines/azure-pipelines.yml index 43d729a42e..3d89b37939 100644 --- a/scripts/azure-pipelines/azure-pipelines.yml +++ b/scripts/azure-pipelines/azure-pipelines.yml @@ -2,8 +2,8 @@ # SPDX-License-Identifier: MIT # variables: - windows-pool: 'PrWin-2021-07-09' - linux-pool: 'PrLin-2021-07-13' + windows-pool: 'PrWin-2021-07-14' + linux-pool: 'PrLin-2021-07-14' osx-pool: 'PrOsx-2021-04-16' stages: diff --git a/scripts/azure-pipelines/linux/create-vmss.ps1 b/scripts/azure-pipelines/linux/create-vmss.ps1 index 52ce23774f..d5651bd8e3 100755 --- a/scripts/azure-pipelines/linux/create-vmss.ps1 +++ b/scripts/azure-pipelines/linux/create-vmss.ps1 @@ -20,9 +20,11 @@ This script assumes you have installed the OpenSSH Client optional Windows compo $Location = 'westus2' $Prefix = 'PrLin-' + (Get-Date -Format 'yyyy-MM-dd') -$VMSize = 'Standard_D32_v4' +$VMSize = 'Standard_D32ds_v4' $ProtoVMName = 'PROTOTYPE' $LiveVMPrefix = 'BUILD' +$MakeInstalledDisk = $false +$InstalledDiskSizeInGB = 1024 $ErrorActionPreference = 'Stop' $ProgressActivity = 'Creating Scale Set' @@ -189,6 +191,12 @@ $SasToken = New-AzStorageAccountSASToken ` $SasToken = $SasToken.Substring(1) # strip leading ? +Write-Progress ` + -Activity $ProgressActivity ` + -Status 'Creating storage account' ` + -CurrentOperation 'Locking down network' ` + -PercentComplete (100 / $TotalProgress * $CurrentProgress) # note no ++ + # Note that we put the storage account into the firewall after creating the above SAS token or we # would be denied since the person running this script isn't one of the VMs we're creating here. Set-AzStorageAccount ` @@ -292,7 +300,8 @@ Set-AzVM ` $VM = Get-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName $PrototypeOSDiskName = $VM.StorageProfile.OsDisk.Name $ImageConfig = New-AzImageConfig -Location $Location -SourceVirtualMachineId $VM.ID -$Image = New-AzImage -Image $ImageConfig -ImageName $ProtoVMName -ResourceGroupName $ResourceGroupName +$ImageName = "$Prefix-BaseImage" +$Image = New-AzImage -Image $ImageConfig -ImageName $ImageName -ResourceGroupName $ResourceGroupName #################################################################################################### Write-Progress ` @@ -333,28 +342,41 @@ $Vmss = Add-AzVmssNetworkInterfaceConfiguration ` $VmssPublicKey = New-Object -TypeName 'Microsoft.Azure.Management.Compute.Models.SshPublicKey' ` -ArgumentList @('/home/AdminUser/.ssh/authorized_keys', $sshPublicKey) -$Vmss = Set-AzVmssOsProfile ` - -VirtualMachineScaleSet $Vmss ` - -ComputerNamePrefix $LiveVMPrefix ` - -AdminUsername AdminUser ` - -AdminPassword $AdminPW ` - -LinuxConfigurationDisablePasswordAuthentication $true ` - -PublicKey @($VmssPublicKey) ` - -CustomData ([Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("#!/bin/bash`n/etc/provision-disks.sh`n"))) +if ($MakeInstalledDisk) { + $Vmss = Set-AzVmssOsProfile ` + -VirtualMachineScaleSet $Vmss ` + -ComputerNamePrefix $LiveVMPrefix ` + -AdminUsername AdminUser ` + -AdminPassword $AdminPW ` + -LinuxConfigurationDisablePasswordAuthentication $true ` + -PublicKey @($VmssPublicKey) ` + -CustomData ([Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("#!/bin/bash`n/etc/provision-disks.sh`n"))) +} else { + $Vmss = Set-AzVmssOsProfile ` + -VirtualMachineScaleSet $Vmss ` + -ComputerNamePrefix $LiveVMPrefix ` + -AdminUsername AdminUser ` + -AdminPassword $AdminPW ` + -LinuxConfigurationDisablePasswordAuthentication $true ` + -PublicKey @($VmssPublicKey) +} $Vmss = Set-AzVmssStorageProfile ` -VirtualMachineScaleSet $Vmss ` -OsDiskCreateOption 'FromImage' ` - -OsDiskCaching ReadWrite ` + -OsDiskCaching ReadOnly ` + -DiffDiskSetting Local ` -ImageReferenceId $Image.Id -$Vmss = Add-AzVmssDataDisk ` - -VirtualMachineScaleSet $Vmss ` - -Lun 0 ` - -Caching 'ReadWrite' ` - -CreateOption Empty ` - -DiskSizeGB 1024 ` - -StorageAccountType 'StandardSSD_LRS' +if ($MakeInstalledDisk) { + $Vmss = Add-AzVmssDataDisk ` + -VirtualMachineScaleSet $Vmss ` + -Lun 0 ` + -Caching 'ReadWrite' ` + -CreateOption Empty ` + -DiskSizeGB $InstalledDiskSizeInGB ` + -StorageAccountType 'StandardSSD_LRS' +} New-AzVmss ` -ResourceGroupName $ResourceGroupName ` diff --git a/scripts/azure-pipelines/windows/create-vmss.ps1 b/scripts/azure-pipelines/windows/create-vmss.ps1 index c3ea470d74..7e93dded48 100644 --- a/scripts/azure-pipelines/windows/create-vmss.ps1 +++ b/scripts/azure-pipelines/windows/create-vmss.ps1 @@ -15,13 +15,6 @@ This script assumes you have installed Azure tools into PowerShell by following at https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-3.6.1 or are running from Azure Cloud Shell. -.PARAMETER Unstable -If this parameter is set, the machine is configured for use in the "unstable" pool used for testing -the compiler rather than for testing vcpkg. Differences: -* The machine prefix is changed to VcpkgUnstable instead of PrWin. -* No storage account or "archives" share is provisioned. -* The firewall is not opened to allow communication with Azure Storage. - .PARAMETER CudnnPath The path to a CUDNN zip file downloaded from NVidia official sources (e.g. https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.1.1.33/11.2_20210301/cudnn-11.2-windows-x64-v8.1.1.33.zip @@ -30,28 +23,28 @@ downloaded in a browser with an NVidia account logged in.) [CmdLetBinding()] Param( - [switch]$Unstable = $false, [parameter(Mandatory=$true)] [string]$CudnnPath ) $Location = 'westus2' -if ($Unstable) { - $Prefix = 'VcpkgUnstable-' -} else { - $Prefix = 'PrWin-' -} +$Prefix = 'PrWin-' $Prefix += (Get-Date -Format 'yyyy-MM-dd') -$VMSize = 'Standard_D32_v4' +$VMSize = 'Standard_D32ds_v4' $ProtoVMName = 'PROTOTYPE' $LiveVMPrefix = 'BUILD' $WindowsServerSku = '2019-Datacenter' +$MakeInstalledDisk = $false $InstalledDiskSizeInGB = 1024 $ErrorActionPreference = 'Stop' $ProgressActivity = 'Creating Scale Set' -$TotalProgress = 21 +$TotalProgress = 20 +if ($MakeInstalledDisk) { + $TotalProgress++ +} + $CurrentProgress = 1 Import-Module "$PSScriptRoot/../create-vmss-helpers.psm1" -DisableNameChecking @@ -274,14 +267,16 @@ $VM = Set-AzVMSourceImage ` -Version latest $InstallDiskName = $ProtoVMName + "InstallDisk" -$VM = Add-AzVMDataDisk ` - -Vm $VM ` - -Name $InstallDiskName ` - -Lun 0 ` - -Caching ReadWrite ` - -CreateOption Empty ` - -DiskSizeInGB $InstalledDiskSizeInGB ` - -StorageAccountType 'StandardSSD_LRS' +if ($MakeInstalledDisk) { + $VM = Add-AzVMDataDisk ` + -Vm $VM ` + -Name $InstallDiskName ` + -Lun 0 ` + -Caching ReadWrite ` + -CreateOption Empty ` + -DiskSizeInGB $InstalledDiskSizeInGB ` + -StorageAccountType 'StandardSSD_LRS' +} $VM = Set-AzVMBootDiagnostic -VM $VM -Disable New-AzVm ` @@ -437,8 +432,10 @@ try { Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName #################################################################################################### -Invoke-ScriptWithPrefix -ScriptName 'deploy-install-disk.ps1' -Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName +if ($MakeInstalledDisk) { + Invoke-ScriptWithPrefix -ScriptName 'deploy-install-disk.ps1' + Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName +} #################################################################################################### Write-Progress ` @@ -481,7 +478,8 @@ Set-AzVM ` $VM = Get-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName $PrototypeOSDiskName = $VM.StorageProfile.OsDisk.Name $ImageConfig = New-AzImageConfig -Location $Location -SourceVirtualMachineId $VM.ID -$Image = New-AzImage -Image $ImageConfig -ImageName $ProtoVMName -ResourceGroupName $ResourceGroupName +$ImageName = "$Prefix-BaseImage" +$Image = New-AzImage -Image $ImageConfig -ImageName $ImageName -ResourceGroupName $ResourceGroupName #################################################################################################### Write-Progress ` @@ -491,7 +489,9 @@ Write-Progress ` Remove-AzVM -Id $VM.ID -Force Remove-AzDisk -ResourceGroupName $ResourceGroupName -DiskName $PrototypeOSDiskName -Force -Remove-AzDisk -ResourceGroupName $ResourceGroupName -DiskName $InstallDiskName -Force +if ($MakeInstalledDisk) { + Remove-AzDisk -ResourceGroupName $ResourceGroupName -DiskName $InstallDiskName -Force +} #################################################################################################### Write-Progress ` @@ -526,12 +526,13 @@ $Vmss = Set-AzVmssOsProfile ` -AdminUsername 'AdminUser' ` -AdminPassword $AdminPW ` -WindowsConfigurationProvisionVMAgent $true ` - -WindowsConfigurationEnableAutomaticUpdate $true + -WindowsConfigurationEnableAutomaticUpdate $false $Vmss = Set-AzVmssStorageProfile ` -VirtualMachineScaleSet $Vmss ` -OsDiskCreateOption 'FromImage' ` - -OsDiskCaching ReadWrite ` + -OsDiskCaching ReadOnly ` + -DiffDiskSetting Local ` -ImageReferenceId $Image.Id New-AzVmss `