mirror of
https://github.com/actions/runner-images.git
synced 2025-12-19 08:22:12 +00:00
Separate VM resizing and moving into two different scripts (#7584)
This commit is contained in:
committed by
GitHub
parent
eb53372646
commit
4ca86478ee
20
.github/workflows/macos-generation.yml
vendored
20
.github/workflows/macos-generation.yml
vendored
@@ -174,20 +174,28 @@ jobs:
|
|||||||
- name: Move vm to cold storage and clear datastore tag
|
- name: Move vm to cold storage and clear datastore tag
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
run: |
|
run: |
|
||||||
$cpuCount = 3
|
|
||||||
$coresPerSocketCount = 3
|
|
||||||
$memory = 14336
|
|
||||||
|
|
||||||
./images.CI/macos/move-vm.ps1 `
|
./images.CI/macos/move-vm.ps1 `
|
||||||
-VMName "${{ env.VM_NAME }}" `
|
-VMName "${{ env.VM_NAME }}" `
|
||||||
-TargetDataStore "${{ inputs.target_datastore }}" `
|
-TargetDataStore "${{ inputs.target_datastore }}" `
|
||||||
-VIServer "${{ secrets.VISERVER_V2 }}" `
|
-VIServer "${{ secrets.VISERVER_V2 }}" `
|
||||||
-VIUserName "${{ secrets.VI_USER_NAME }}" `
|
-VIUserName "${{ secrets.VI_USER_NAME }}" `
|
||||||
-VIPassword "${{ secrets.VI_PASSWORD }}" `
|
-VIPassword "${{ secrets.VI_PASSWORD }}" `
|
||||||
-JobStatus "${{ job.status }}" `
|
-JobStatus "${{ job.status }}"
|
||||||
|
|
||||||
|
- name: Set VM size
|
||||||
|
run: |
|
||||||
|
$cpuCount = 3
|
||||||
|
$coresPerSocketCount = 3
|
||||||
|
$memory = 14336
|
||||||
|
|
||||||
|
./images.CI/macos/set-vm-size.ps1 `
|
||||||
|
-VMName "${{ env.VM_NAME }}" `
|
||||||
-CpuCount "$cpuCount" `
|
-CpuCount "$cpuCount" `
|
||||||
-CoresPerSocketCount "$coresPerSocketCount" `
|
-CoresPerSocketCount "$coresPerSocketCount" `
|
||||||
-Memory "$memory"
|
-Memory "$memory" `
|
||||||
|
-VIServer "${{ secrets.VISERVER_V2 }}" `
|
||||||
|
-VIUserName "${{ secrets.VI_USER_NAME }}" `
|
||||||
|
-VIPassword "${{ secrets.VI_PASSWORD }}"
|
||||||
|
|
||||||
- name: Destroy VM (if build canceled only)
|
- name: Destroy VM (if build canceled only)
|
||||||
if: ${{ cancelled() }}
|
if: ${{ cancelled() }}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ try {
|
|||||||
$vm = Get-VM $VMName
|
$vm = Get-VM $VMName
|
||||||
if (($env:AGENT_JOBSTATUS -and $env:AGENT_JOBSTATUS -eq 'Failed') -or ($JobStatus -and $JobStatus -eq 'failure')) {
|
if (($env:AGENT_JOBSTATUS -and $env:AGENT_JOBSTATUS -eq 'Failed') -or ($JobStatus -and $JobStatus -eq 'failure')) {
|
||||||
try {
|
try {
|
||||||
if($vm.PowerState -ne "PoweredOff") {
|
if ($vm.PowerState -ne "PoweredOff") {
|
||||||
Stop-VM -VM $vm -Confirm:$false -ErrorAction Stop | Out-Null
|
Stop-VM -VM $vm -Confirm:$false -ErrorAction Stop | Out-Null
|
||||||
}
|
}
|
||||||
Set-VM -VM $vm -Name "${VMName}_failed" -Confirm:$false -ErrorAction Stop | Out-Null
|
Set-VM -VM $vm -Name "${VMName}_failed" -Confirm:$false -ErrorAction Stop | Out-Null
|
||||||
@@ -84,11 +84,3 @@ try {
|
|||||||
Write-Host "##vso[task.LogIssue type=error;]Failed to move VM '$VMName' to target datastore '$TargetDataStore'"
|
Write-Host "##vso[task.LogIssue type=error;]Failed to move VM '$VMName' to target datastore '$TargetDataStore'"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
Write-Host "Change CPU count to $CpuCount, cores count to $CoresPerSocketCount, amount of RAM to $Memory"
|
|
||||||
$vm | Set-VM -NumCPU $CpuCount -CoresPerSocket $CoresPerSocketCount -MemoryMB $Memory -Confirm:$false -ErrorAction Stop | Out-Null
|
|
||||||
} catch {
|
|
||||||
Write-Host "##vso[task.LogIssue type=error;]Failed to change specs for VM '$VMName'"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|||||||
73
images.CI/macos/set-vm-size.ps1
Normal file
73
images.CI/macos/set-vm-size.ps1
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
This script sets resources for VM
|
||||||
|
|
||||||
|
.PARAMETER VMName
|
||||||
|
VM name to resize (Example "macOS-10.15_20201012.4")
|
||||||
|
|
||||||
|
.PARAMETER VIServer
|
||||||
|
vCenter address (Example "10.0.1.16")
|
||||||
|
|
||||||
|
.PARAMETER VIUserName
|
||||||
|
vCenter username (Example "Administrator")
|
||||||
|
|
||||||
|
.PARAMETER VIPassword
|
||||||
|
vCenter password (Example "12345678")
|
||||||
|
|
||||||
|
.PARAMETER CpuCount
|
||||||
|
Target number of CPUs (Example "3")
|
||||||
|
|
||||||
|
.PARAMETER CoresPerSocketCount
|
||||||
|
Target number of cores per socket (Example "3")
|
||||||
|
|
||||||
|
.PARAMETER Memory
|
||||||
|
Target amount of memory in MB (Example "14336")
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$VMName,
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$VIServer,
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$VIUserName,
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$VIPassword,
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[int32]$CpuCount,
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[int32]$CoresPerSocketCount,
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[int64]$Memory
|
||||||
|
)
|
||||||
|
|
||||||
|
# Import helpers module
|
||||||
|
Import-Module $PSScriptRoot\helpers.psm1 -DisableNameChecking
|
||||||
|
|
||||||
|
# Connection to a vCenter Server system
|
||||||
|
Connect-VCServer -VIServer $VIServer -VIUserName $VIUserName -VIPassword $VIPassword
|
||||||
|
|
||||||
|
$vm = Get-VM $VMName
|
||||||
|
try {
|
||||||
|
Write-Host "Change CPU count to $CpuCount, cores count to $CoresPerSocketCount, amount of RAM to $Memory"
|
||||||
|
$vm | Set-VM -NumCPU $CpuCount -CoresPerSocket $CoresPerSocketCount -MemoryMB $Memory -Confirm:$false -ErrorAction Stop | Out-Null
|
||||||
|
} catch {
|
||||||
|
Write-Host "##vso[task.LogIssue type=error;]Failed to change specs for VM '$VMName'"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user