VMware Cloud Community
MattHumphreys
Contributor
Contributor

Identifying tasks created by disabling HA and tracking progress - Script to enter maintenance mode

So we have a couple of clusters that contain only 2 hosts for management-related functions, I am trying to automate placing a single host into maintenance mode for our support team to be able to handle hardware related faults and issues both in clusters with greater than 2 hosts and 2 hosts only.

I have made some progress but my challenge has come from one location, disabling HA.

I have the method to do it but the challenge is that you send "Set-Cluster -Cluster $cluster -HAEnabled:$false" and it immediately returns "done" but it isnt, it then spawns a whole bunch of child tasks/processes, Reconfiguring the cluster, removing the Solution, configuring the hosts and then checking compliance which can take an unknown amount of time.

I am really struggling to find a consistent way of identifying those tasks and tracking them and waiting till they are completed and then proceeding to place the host in maintenance mode.

The user/initiator is not consistent (sometimes its the requestor who runs the script, sometimes its VPXD sometimes its "System")

There doesnt appear to be a parent ID that I am seeing linking the tasks together, I cant just grab all tasks based on running status because there are other things going on, Veeam backups and other system tasks so I cant just wait for everything to stop.

I am kinda stumped on this one, I did look at the VCHA module someone wrote but that seems to apply to all clusters in the entire vcenter and I couldnt see a way to just limit it to a single cluster.

Anyone has any suggestions it would be much appreciated.

0 Kudos
4 Replies
LucD
Leadership
Leadership

Isn't that VCHA module intended for cluster vCenters?

Does the HAEnabled property in the object returned by Get-Cluster immediately say $false?
Before all these tasks are completed.
Otherwise you can just do Get-CLuster in a loop and wait for the property to flip


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

0 Kudos
MattHumphreys
Contributor
Contributor

Yes sadly that flips immediately to $false while the tasks are still running,

I have queried the hosts for .ExtensionData.Runtime.DasHostState.State and that also immediately changes when you disable it.

I have tried looking for the compliance task as that is supposedly the last thing to finish but that is also an unreliable measure of HA status as it can be triggered by other things and if someone else runs a compliance check how do I know its the one for my request

0 Kudos
LucD
Leadership
Leadership

When you look for the cluster under Monitoring - Task, and search for the reconfigure cluster task.
When you open that task, are any related tasks shown?


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

0 Kudos
MattHumphreys
Contributor
Contributor

So the reconfigure cluster has a bunch of related events but the check compliance one is not one of those tasks so they dont appear to be related and the unconfiguring of the solution from the hosts is also not in that list of related events and they finish at a different time.

I am basically coming to the point where I feel that I need to do two scripts/steps so one to disable the HA element and the staff just have to watch and wait for tasks to finish then instigate step two which is for the enter maintenance mode part rather than try to do them at the same time.

0 Kudos