From afdfb79220a6fea91f7ed84b2c747c584b5b9779 Mon Sep 17 00:00:00 2001 From: Philipp Wollermann Date: Tue, 1 May 2018 11:01:49 +0200 Subject: [PATCH] Disable usage of local SSD on Windows VMs. Workaround for https://github.com/bazelbuild/bazel/issues/5125. --- buildkite/create_instances.py | 4 +++- buildkite/setup-windows.ps1 | 12 ++++++------ buildkite/startup-windows.ps1 | 35 +++++++++++------------------------ 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/buildkite/create_instances.py b/buildkite/create_instances.py index 8af7169220..21b4ab6d92 100755 --- a/buildkite/create_instances.py +++ b/buildkite/create_instances.py @@ -92,7 +92,9 @@ 'buildkite-worker-windows-java8': { 'count': 8, 'image_family': 'buildkite-worker-windows-java8', - 'local_ssd': 'interface=scsi', + # We need to boost the size in order to get better IOPS and throughput. + # See: https://cloud.google.com/compute/docs/disks/performance + 'boot_disk_size': '1000GB', 'metadata_from_file': 'windows-startup-script-ps1=startup-windows.ps1', }, } diff --git a/buildkite/setup-windows.ps1 b/buildkite/setup-windows.ps1 index b475d2bdbd..36261c2e8a 100755 --- a/buildkite/setup-windows.ps1 +++ b/buildkite/setup-windows.ps1 @@ -270,8 +270,8 @@ SET BUILDKITE_ARTIFACT_UPLOAD_DESTINATION=gs://bazel-buildkite-artifacts/%BUILDK SET BUILDKITE_GS_ACL=publicRead SET JAVA_HOME=${env:JAVA_HOME} SET PATH=${env:PATH} -SET TEMP=D:\temp -SET TMP=D:\temp +SET TEMP=C:\temp +SET TMP=C:\temp "@ [System.IO.File]::WriteAllLines("${buildkite_agent_root}\hooks\environment.bat", $buildkite_environment_hook) @@ -296,10 +296,10 @@ Write-Host "Terminating all processes belonging to the `${buildkite_username} us & taskkill /FI "username eq `${buildkite_username}" /T /F Start-Sleep -Seconds 1 -Write-Host "Recreating fresh temporary directory D:\temp..." -Remove-Item -Recurse -Force "D:\temp" -New-Item -Type Directory "D:\temp" -Add-NTFSAccess -Path "D:\temp" -Account BUILTIN\Users -AccessRights Write +Write-Host "Recreating fresh temporary directory C:\temp..." +Remove-Item -Recurse -Force "C:\temp" +New-Item -Type Directory "C:\temp" +Add-NTFSAccess -Path "C:\temp" -Account BUILTIN\Users -AccessRights Write Write-Host "Deleting home directory of the `${buildkite_username} user..." Get-CimInstance Win32_UserProfile | Where LocalPath -EQ "C:\Users\`${buildkite_username}" | Remove-CimInstance diff --git a/buildkite/startup-windows.ps1 b/buildkite/startup-windows.ps1 index 59590b3334..c30254d214 100755 --- a/buildkite/startup-windows.ps1 +++ b/buildkite/startup-windows.ps1 @@ -2,46 +2,33 @@ $ErrorActionPreference = "Stop" $ConfirmPreference = "None" -## Initialize, partition and format the local SSD. -Write-Host "Initializing local SSD..." -if ((Get-Disk -Number 1).PartitionStyle -ne "RAW") { - Clear-Disk -Number 1 -RemoveData -RemoveOEM -} -Initialize-Disk -Number 1 -New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter D -Format-Volume -DriveLetter D -ShortFileNameSupport $true ## Load PowerShell support for ZIP files. Add-Type -AssemblyName "System.IO.Compression.FileSystem" ## Remove write access to volumes for unprivileged users. Write-Host "Setting NTFS permissions..." Remove-NTFSAccess "C:\" -Account BUILTIN\Users -AccessRights Write -Remove-NTFSAccess "D:\" -Account BUILTIN\Users -AccessRights Write - -## Create temporary folder (D:\temp). -Write-Host "Creating temporary folder on local SSD..." -New-Item "D:\temp" -ItemType "directory" -Add-NTFSAccess "D:\temp" -Account BUILTIN\Users -AccessRights Write +Add-NTFSAccess "C:\temp" -Account BUILTIN\Users -AccessRights Write -## Redirect MSYS2's tmp folder to D:\temp +## Redirect MSYS2's tmp folder to C:\temp Remove-Item -Recurse -Force C:\tools\msys64\tmp -New-Item -ItemType Junction -Path "C:\tools\msys64\tmp" -Value "D:\temp" +New-Item -ItemType Junction -Path "C:\tools\msys64\tmp" -Value "C:\temp" -## Create Buildkite agent working directory (D:\build). -Write-Host "Creating build folder on local SSD..." -New-Item "D:\build" -ItemType "directory" -Add-NTFSAccess "D:\build" -Account BUILTIN\Users -AccessRights Write +## Create Buildkite agent working directory (C:\build). +Write-Host "Creating build folder..." +New-Item "C:\build" -ItemType "directory" +Add-NTFSAccess "C:\build" -Account BUILTIN\Users -AccessRights Write ## Setup the TEMP and TMP environment variables. -[Environment]::SetEnvironmentVariable("TEMP", "D:\temp", "Machine") -[Environment]::SetEnvironmentVariable("TMP", "D:\temp", "Machine") +[Environment]::SetEnvironmentVariable("TEMP", "C:\temp", "Machine") +[Environment]::SetEnvironmentVariable("TMP", "C:\temp", "Machine") $env:TEMP = [Environment]::GetEnvironmentVariable("TEMP", "Machine") $env:TMP = [Environment]::GetEnvironmentVariable("TMP", "Machine") ## Download the Buildkite agent token. Write-Host "Getting Buildkite Agent token from GCS..." $buildkite_agent_token_url = "https://storage.googleapis.com/bazel-encrypted-secrets/buildkite-agent-token.enc" -$buildkite_agent_token_file = "d:\buildkite_agent_token.enc" +$buildkite_agent_token_file = "C:\buildkite_agent_token.enc" (New-Object Net.WebClient).DownloadFile($buildkite_agent_token_url, $buildkite_agent_token_file) ## Decrypt the Buildkite agent token. @@ -67,7 +54,7 @@ $buildkite_agent_config = @" token="${buildkite_agent_token}" name="%hostname-%n" tags="kind=worker,os=windows,java=8,image-version=${image_version}" -build-path="d:\build" +build-path="c:\build" hooks-path="c:\buildkite\hooks" plugins-path="c:\buildkite\plugins" git-clone-flags="-v --reference c:\buildkite\bazelbuild"