Skip to content

Commit bb45543

Browse files
authored
Move the Arm64 PGO VM to a new resource group and add docs (#432)
1 parent c040a1b commit bb45543

2 files changed

Lines changed: 86 additions & 8 deletions

File tree

windows-release/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,79 @@ Note that regular signing checks (such as `signtool.exe verify /pa python.exe`)
7373
and malware scans will treat the files as correctly signed.
7474
It's only more complicated to verify that it was signed _specifically_ with our cert.
7575

76+
## Auto-start ARM64 VM
77+
78+
Until Azure Pipelines offers ARM64 machines as standard, we use a custom VM to run PGO profiling.
79+
This VM is hosted on Steve's subscription and is automatically launched by the start-arm64vm.yml stage.
80+
81+
To replicate the configuration for a new subscription or VM, here are the steps:
82+
83+
* Visit https://dev.azure.com/Python/cpython/_settings/adminservices to update/create an
84+
Azure Resource Manager connection using Workload Identity Federation (a.k.a. OIDC).
85+
* Create two custom roles in your Azure Subscription. The full JSON for each role is below,
86+
and can be uploaded to the Azure Portal as a starting point for the role.
87+
* Assign the "VM Restarter" role to the service principal/account used for WIF *on the resource group*
88+
* Assign the "VM Updater" role to the service principal *on the VM*. This allows the VM to be updated,
89+
but does not allow the workflow permission to create new VMs.
90+
* Visit https://dev.azure.com/Python/cpython/_settings/agentqueues?queueId=24&view=agents and click
91+
"New agent" to get the download URL for the Azure Pipelines agent. Extract onto the VM an run `config.cmd`.
92+
Give `https://dev.azure.com/Python` as the server URL.
93+
* Visit https://dev.azure.com/Python/_usersSettings/tokens to create a PAT with "Agent Pools (Read & manage)"
94+
scope and paste it into the VM's config script when prompted.
95+
* Give "Windows ARM64" as the pool name; any (unique) agent name is okay.
96+
* Ensure Git is installed on the VM and you're ready to run.
97+
98+
The VM Restarter role (manually set the assignable scopes to your subscription after uploading to the portal):
99+
100+
```json
101+
{
102+
"properties": {
103+
"roleName": "VM Restarter",
104+
"description": "Allows starting, stopping, and scheduling of VMs.",
105+
"assignableScopes": [],
106+
"permissions": [
107+
{
108+
"actions": [
109+
"Microsoft.Compute/virtualMachines/read",
110+
"Microsoft.Compute/virtualMachines/start/action",
111+
"Microsoft.Compute/virtualMachines/powerOff/action",
112+
"Microsoft.Compute/virtualMachines/restart/action",
113+
"Microsoft.Compute/virtualMachines/deallocate/action",
114+
"Microsoft.DevTestLab/schedules/delete",
115+
"Microsoft.DevTestLab/schedules/read",
116+
"Microsoft.DevTestLab/schedules/write",
117+
"Microsoft.DevTestLab/schedules/Execute/action",
118+
"Microsoft.DevTestLab/schedules/Retarget/action"
119+
],
120+
"notActions": [],
121+
"dataActions": [],
122+
"notDataActions": []
123+
}
124+
]
125+
}
126+
}
127+
```
128+
129+
The VM Updater role:
130+
131+
```json
132+
{
133+
"properties": {
134+
"roleName": "VM Updater",
135+
"description": "Allows creating or modifying VMs.",
136+
"assignableScopes": [],
137+
"permissions": [
138+
{
139+
"actions": [
140+
"Microsoft.Compute/virtualMachines/write"
141+
],
142+
"notActions": [],
143+
"dataActions": [],
144+
"notDataActions": []
145+
}
146+
]
147+
}
148+
}
149+
```
150+
76151
(Further documentation to be added as we find out what ought to be documented.)

windows-release/start-arm64vm.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
parameters:
22
DoARM64: false
33
DoPGOARM64: false
4+
ServiceConnection: "Steve's VM"
5+
ResourceGroup: 'pythonarm64'
6+
VMName: 'pythonarm64'
47

58
jobs:
69
# Only include the job if we need the VM, which means ARM64 PGO.
@@ -13,25 +16,25 @@ jobs:
1316
- checkout: none
1417

1518
- task: AzureCLI@2
16-
displayName: 'Start pythonarm64 and set auto-shutdown to (UTC now - 1h)'
19+
displayName: 'Start ARM64 VM and set auto-shutdown to (UTC now + 8h)'
1720
inputs:
18-
azureSubscription: "Steve's VM" # WIF service connection name
21+
azureSubscription: ${{ parameters.ServiceConnection }}
1922
scriptType: pscore
2023
scriptLocation: inlineScript
2124
inlineScript: |
2225
$ErrorActionPreference = 'Stop'
2326
24-
$rg = 'cpythonbuild'
25-
$vm = 'pythonarm64'
27+
$rg = '${{ parameters.ResourceGroup }}'
28+
$vm = '${{ parameters.VMName }}'
2629
27-
# Compute UTC time minus 12 hours, format HHmm (e.g. 1830)
28-
$shutdownTime = (Get-Date).ToUniversalTime().AddHours(-12).ToString('HHmm')
30+
# Compute UTC time plus 8 hours, format HHmm (e.g. 1830)
31+
$shutdownTime = (Get-Date).ToUniversalTime().AddHours(8).ToString('HHmm')
2932
Write-Host "Setting auto-shutdown time to: $shutdownTime UTC"
3033
31-
# Configure daily auto-shutdown in 12 hours
34+
# Configure daily auto-shutdown in 8 hours
3235
az vm auto-shutdown -g $rg -n $vm --time $shutdownTime | Out-Null
3336
if ($?) {
34-
Write-Host "Successfully configured auto-shutdown for ARM64 VM in 12 hours."
37+
Write-Host "Successfully configured auto-shutdown for ARM64 VM in 8 hours."
3538
} else {
3639
Write-Host "##[warning]Failed to configure ARM64 VM auto-shutdown."
3740
}

0 commit comments

Comments
 (0)