aatef6
Contributor
Contributor

VMs did not fetch new VM settings on first run

Jump to solution

Hello Experts,

I have the below script to add/modify some VMSettings in our cluster. We first powered off the VMs then ran the script which showed that it is setting the values for both new advanced settings the "followcorespersocket and the numa.autosize.vcpu.maxPerVirtualNode. After the script finished, we ran verification and it showed that the values for both VM settings is correct on all VMs. We started powering on the  VMs but the VMs were not stable so we powered them down and then re-ran a verification script to find that the VMs only copied the first VM setting only but not the second one even though the verification right after the script fifnished showed both correctly!

We powered down the VMs again, ran the script again, seems like the script got the second VM setting the second time right. Powered on the VMs, they were stable, then ran the verification and everything seems correct. Does any body know why did the VMs did not copy both VM settings correctly on the first run? Do we need to introduce a pause in between the two commands for a few seconds to give the VM a chance to copy the new VM settings correctly? Your inputs is highly appreciated. Thanks

$vms = get-vm | where {$_.Name -like "*MCM*"} | where {$_.PowerState -eq "PoweredOff"}

foreach ($vm in $vms) {

Write-Host "Processing VM $vm" -ForegroundColor green

$followcorespersocketvalue = (Get-AdvancedSetting -Entity $vm -Name numa.vcpu.followcorespersocket).value

if ($followcorespersocketvalue -eq 1)

{

Write-Host "numa.vcpu.followcorespersocket key already exists and set correctly" -ForegroundColor green

}

else{

Write-Host "numa.vcpu.followcorespersocket key might already exists but not set correctly or does not exist at all - Setting the value for VM $vm" -ForegroundColor red

New-AdvancedSetting -Entity $vm -Name numa.vcpu.followcorespersocket -Value 1 -Confirm:$false -Force:$true

}

$numaautosize = (Get-AdvancedSetting -Entity $vm -Name numa.autosize.vcpu.maxPerVirtualNode).value

$AdvancedSettingDesiredValue = (Get-AdvancedSetting -Entity $vm -Name cpuid.coresPerSocket | select Value).value

if ($numaautosize -eq $AdvancedSettingDesiredValue )

{

Write-Host "numa.autosize.vcpu.maxPerVirtualNode key already exists and is set correctly equal to the cpuid.coresPerSocket value" -ForegroundColor green

}

else{

Write-Host "numa.autosize.vcpu.maxPerVirtualNode key might already exist, and might not be existing or set incorrectly" -ForegroundColor red

New-AdvancedSetting -Entity $vm -Name numa.autosize.vcpu.maxPerVirtualNode -Value $AdvancedSettingDesiredValue -Confirm:$false -Force:$true

}

Write-Host ""

}

Thanks @

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

As far as I can tell, your script might have a couple of flaws when, nor numa.autosize.vcpu.maxPerVirtualNode nor cpuid.coresPerSocket are set.

In that case your condition $numaautosize -eq $AdvancedSettingDesiredValue will also be true (both variables are empty) and nothing will be set.

Also, the advanced setting numa.autosize.vcpu.maxPerVirtualNode will only contain a value after a poweron/poweroff of the VM, after you set the numa.vcpu.followcorespersocket setting.

And finally, the setting cpuid.coresPerSocket will only have a value when you have defined cores per socket. Otherwise the setting will return $null


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership

As far as I can tell, your script might have a couple of flaws when, nor numa.autosize.vcpu.maxPerVirtualNode nor cpuid.coresPerSocket are set.

In that case your condition $numaautosize -eq $AdvancedSettingDesiredValue will also be true (both variables are empty) and nothing will be set.

Also, the advanced setting numa.autosize.vcpu.maxPerVirtualNode will only contain a value after a poweron/poweroff of the VM, after you set the numa.vcpu.followcorespersocket setting.

And finally, the setting cpuid.coresPerSocket will only have a value when you have defined cores per socket. Otherwise the setting will return $null


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
aatef6
Contributor
Contributor

Thanks a lot Luc for your response .. the cpuid.coresPerSocket setting has already been there since the beginning on all VMs .. i'm only copying its value and putting it into the numa.autosize.vcpu.maxPerVirtualNode setting.

I have looked at the prerun verification and could see that the VMs had the cpuid.coresPerSocket set but not the FollowCoresPerSocket neither the numa.autosize so i think your second point is right. After the first run when the follow cores were added then we powered on/off then we were able to add the numa.autosize.vcpu .. this clarifies it all since i did not know there is a dependency that required that we power on the VMs after adding the follow cores per socket then Power off then apply the second vm-setting "numa.autosize.vcpu".

NameMax vCPU per NUMACores Per SocketFollow Cores Per SocketPower State
XXXXXXXX18poweredOff

one question i have, why did the PowerShell allowed us to change the numa.autosize.vcpu.maxPerVirtualNode and showed success when it should have rejected until the followcorespersocket  went into effect after powering on the VMs?

Thanks a lot .. appreciate your help

0 Kudos
LucD
Leadership
Leadership

The underlying method that changes the advanced setting doesn't take that into account.
There is no advanced error checking on what you assign.

In fact your script should check the validity of the value you are trying to set.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
aatef6
Contributor
Contributor

Thanks a lot Luc .. any idea where to get the dependencies of the advanced settings in general? in the below link it does not mention that there is a dependency however logically there should be

Virtual NUMA Controls

0 Kudos
LucD
Leadership
Leadership

No, I'm afraid I don't know any reference like that.

There are documents that describe the advanced settings, but I'm not sure they are all listed, and if they have any dependency info.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos