StarWind iSCSI SAN
StarWind Native SAN for Hyper-V
 

How to get maintenance status

Software-based VM-centric and flash-friendly VM storage + free version, StarWind VSAN "Ready Nodes"

Moderators: art (staff), anton (staff), Anatoly (staff), Max (staff)

How to get maintenance status

Postby wallewek » Thu Oct 15, 2020 8:26 pm

I appreciate the new MaintenanceMode powershell script, but It leaves me with a question or two. Unfortunately the StarWindX PDF documentation appears to be very out of date.

Is there any "get" version of the PowerShell "SwitchMaintenanceMode" function that it uses? It would really be nice to be able to list the maintenance status of devices.

Is there any way to list all the PowerShell functions inside the StarWindX module? I don't mind writing my own PowerShell scripts if I had some sort of list of what I could use. I tried using Get-Command, but SwitchMaintenanceMode doesn't appear to even be listed.

Thanks if you have any suggestions!

--- kenw
------------------------
"In theory, theory and practice are the same, but in practice they're not." -- Yogi Berra
wallewek
 
Posts: 70
Joined: Wed Sep 20, 2017 9:13 pm

Re: How to get maintenance status

Postby yaroslav (staff) » Fri Oct 16, 2020 7:52 am

May I help you with your queries about the MaintenanceMode script?
There is already a sample script that you can fit your individual needs. Yes, it is a sample script that you are welcome to modify as you wish (unless it breaks things of course).
Are you looking for the list of functions or scripts inside the StarWindX module? It will be cool to have a script from you of course :D , but if you request a documentation update, that's something that we should do, I believe.
So my questions are:
1. how can I help you with the MaintenanceMode script?
2. do you request a documentation update?
yaroslav (staff)
Staff
 
Posts: 480
Joined: Mon Nov 18, 2019 11:11 am

Re: How to get maintenance status

Postby wallewek » Fri Oct 16, 2020 3:42 pm

Thank you very much for your response, Yaroslav. I'm sorry, I guess I wasn't very clear.

The biggest problem with the MaintenanceMode script, as I see it, is its lack of reporting. It provides absolutely no way to report on the maintenance mode of any device without changing it.

That's what I want for Maintenance Mode status: a way to GET it, not set it.

As for the documentation, yes, I do request a documentation update. It doesn't need to be verbose, necessarily, but it would be very helpful if it at least fully covered the complete list of set and get functions.

I have been through StarWindX from beginning to end, and appreciate it very much, but it doesn't even provide the bare essential information necessary to get maintenance mode. I would happily add it to the GetHASyncState script I've provided here before, but I can't, without that info.

--- kenw
------------------------
"In theory, theory and practice are the same, but in practice they're not." -- Yogi Berra
wallewek
 
Posts: 70
Joined: Wed Sep 20, 2017 9:13 pm

Re: How to get maintenance status

Postby yaroslav (staff) » Fri Oct 16, 2020 4:15 pm

Hi,

Thanks for your hint. Will request better documentation on StarWindX, and, guess a new script for checking if Maintenance mode is enabled.
By the way, you can check it in StarWind Management Console as the free version provides the monitoring capabilities.
yaroslav (staff)
Staff
 
Posts: 480
Joined: Mon Nov 18, 2019 11:11 am

Re: How to get maintenance status

Postby wallewek » Fri Oct 16, 2020 11:03 pm

Thank you Yaroslav.

Yes, I did not expect to be able to use the StarWind Management Console to check maintenance mode. It does work nicely. That kind of makes using a script to check statuses less important. I have made a bunch of changes to the MaintenanceMode script to make it more clear what is happening, etc. I will provide a copy soon.

However, I now have a problem, after replacing a failing drive (it had not yet failed but diagnostics said it soon would). The replacement seemed to be to be working OK, but now after final mounting in the server (I had it mounted externally for testing) I have a cluster problem. The Microsoft Failover Cluster Manager refuses to bring the CSV drive online, citing an error 1460. And I was very careful to use Maintenance mode before shutting down to do that, too.

The network statuses and iSCSI stuff all look OK too.

I can't see anything wrong with the drive, chkdsk thinks it's fine. However, I'm suspicious of the synchronization status. Using PowerShell, I'm getting HAstatus results that say that the devices are all synchronized, but that the synch percentage is zero -- on some devices, not all.

What's weird is that the StarWind Management Console says the drives are just fine. Quite confusing. I'm quite concerned about PowerShell and the Management console not reporting the same thing.

I'm trying a full one-server-at-a-time reboot without maintenance mode. So far, there's a full resynch taking place on the CSV, but it still refuses to come on line in the Microsoft FCM Not sure how to troubleshoot that.

-- kenw
------------------------
"In theory, theory and practice are the same, but in practice they're not." -- Yogi Berra
wallewek
 
Posts: 70
Joined: Wed Sep 20, 2017 9:13 pm

Re: How to get maintenance status

Postby wallewek » Sun Oct 18, 2020 9:50 pm

OK, the Failover Cluster is back online. I'm really not sure what the real problem was; diagnostics were quite unclear. I suspect something mucked up with the iSCSI targets. It probably doesn't help that the host servers are both domain members, but the domain controllers are virtual guests of the cluster, so can't be reached while bringing up cluster services if the whole cluster is offline.

One thing is consistent, though: PowerShell reporting of device synchronization percentage continues to be... basically broken.
Devices that report as Synchronized in both PowerShell and the StarWind Management Console are showing 0% synchronized. Interestingly, it seems to wander around a bit as to which devices report this way. It's gotten to the point where I basically ignore the PowerShell output; I simply can't trust it.

While I'm here, I'm going to paste in a couple of PowerShell scripts I've been working on for improved friendliness. Do with them what you will.

First, here's the latest GetHASyncState script. It handles everything but device naming, and shows both sides of a two-node VSAN.
Code: Select all
#
# Get synchronization status of specified HA device and if there is a need run synchronization
#

"GetHASYncState -- KW version"

Import-Module StarWindX

while ($true) {

"------------- Running ---------------"

try
{
    #
    # connect to the server
    #
    $server = New-SWServer -host 127.0.0.1 -port 3261 -user root -password starwind

    $server.Connect()

    #
    # Try to find specified device
    #
    $deviceName = "*"
    $partnerTargetName = "*"
    $deviceFound = $false
   
    foreach($device in $server.devices)
    {
            $device.Refresh()
           
            $syncStatus = $device.GetPropertyValue("ha_synch_status")

            Write-Host ""
            Write-Host -NoNewline "DeviceName:" $device.GetPropertyValue("DeviceName") -foreground yellow

            If ( $syncStatus -gt "" )
            {
                $state = $device.GetPropertyValue("state")
               
                Write-Host " -- TargetName:" $device.GetPropertyValue("TargetName")
                Write-Host -foreground yellow -NoNewline "Device state:" $state
               
                $stateText = switch ($state)
                {
                    0 { " (Active)" }
                    1 { " (NonActive)" }
                    2 { " (NotLicensed)" }
                    3 { " (Disabled)" }
                    default { "(Undefined)" }
                }

               Write-Host $stateText  -foreground yellow

               Write-Host -NoNewline "Sync Status:" $syncStatus "" -foreground yellow

               $waitForAutoSync = $device.GetPropertyValue("ha_wait_on_autosynch")
               
                if ( $waitForAutoSync -eq "1" )
                {
                    Write-Host "(Waiting for autosynchronization)" -foreground yellow
                }
                else
                {
                    if ( $syncStatus -eq "1" )
                    {
                        #
                        # Device is synchronized. Get synchronization percent and show it
                        #
                        $syncPercent = $device.GetPropertyValue("ha_synch_percent")                       
                        Write-Host "(Synchronized) -- $($syncPercent)%" -foreground yellow

                    }
                    if ( $syncStatus -eq "2" )
                    {
                        #
                        # Device is synchronizing. Get synchronization percent and show it
                        #
                        $syncPercent = $device.GetPropertyValue("ha_synch_percent")
                        Write-Host "(Synchronizing) -- $($syncPercent)%" -foreground yellow
                    }
                   
                    if ( $syncStatus -eq "3" )
                    {
                        #
                        # Device not synchronized. Synchronize current node from partner
                        #
                        Write-Host "Device not synchronized."
                       
                        # Synchronize current node from partner '$($partnerTargetName)'" -foreground yellow

                       # $params = new-object -ComObject StarWindX.Parameters       
                       # $params.AppendParam("deviceID",$device.DeviceId)
                       # $params.AppendParam("partnetTargetName",$partnerTargetName)
                       
                       # $server.ExecuteCommand( 0, "restoreHAPartnerNode", $params)
                       
                        #
                        # If you want to synchronize partners from current node you can comment out code above and uncomment section below
                        #
                       
                        # Device not synchronized. Mark current node as 'Synchronized'.
                        # WARNING, Command changes Device Status to "Synchronized" without Data Synchronization with HA (High Availability) Partner,
                        # Device will start processing Client Requests immediately and will be used as Data Synchronization Source for Partner Device.
                        #
                        #Write-Host "Device not synchronized. Mark current node as 'Synchronized'. " -foreground yellow

                        #$params = new-object -ComObject StarWindX.Parameters       
                        #$params.AppendParam("deviceID",$device.DeviceId)
                       
                            #$server.ExecuteCommand( 0, "restoreCurrentHANode", $params)
                       
                       # Start-Sleep -m 5000
                    }
                }
#=======
                Write-Host "ha_partner_nodes_count:" $device.GetPropertyValue("ha_partner_nodes_count")

                $status = $device.GetPropertyValue("ha_partner_node1_sync_status")
                $statusText = switch ($device.GetPropertyValue("ha_partner_node1_sync_status") )
                {
                    1 { " (Synchronized)" }
                    2 { " (Synchronizing)" }
                    3 { " (NOT Synchronized)" }
                    default { "(Undefined)" }
                }
                Write-Host "ha_partner_node1_sync_status: $($status)$($StatusText) --" `
                            $device.GetPropertyValue("ha_partner_node1_sync_percent"), "%"
                Write-Host "ha_partner_node1_is_exist_sync_valid_connection:" `
                            $device.GetPropertyValue("ha_partner_node1_is_exist_sync_valid_connection")
                Write-Host "ha_partner_node1_is_exist_heartbeat_valid_connection:" `
                            $device.GetPropertyValue("ha_partner_node1_is_exist_heartbeat_valid_connection")
               
               # Write-Host "ha_partner_node2_sync_status:" $device.GetPropertyValue("ha_partner_node2_sync_status")
               # Write-Host "ha_partner_node2_sync_percent:" $device.GetPropertyValue("ha_partner_node2_sync_status")




            }
            else
            {
                write-host -NoNewLine " -- no info"
            }
    }
   
#    if ( $deviceFound -ne $true )
#    {
#        Write-Host "$($deviceName) not found" -foreground red
#    }

}
catch
{
    Write-Host "Exception $($_.Exception.Message)" -foreground red
}

Write-Host ""

$server.Disconnect( )
pause

}



Second is MaintenanceMode-Choose.ps1, which allows setting or unsetting maintenance mode, with or without Force option. It uses a GUI dialog box to chose the options, so no code editing is needed for that, but you do have to edit it initially for your device names. It doesn't tell you what mode the VSAN is already in, as I know of no way to do that, but it is at least clear about what it does and tells you where to check.

Code: Select all
#modified KW
#NOTE, running on ANY node sets Maintenance mode for a given device on ALL nodes.
#Cluster services should be fully stopped BEFORE using maintenance mode. and all devices should be put into maintenance mode together

param(
    $addr="127.0.0.1", $port=3261, $user="root", $password="starwind", `
    $deviceName1="HAImage1", `
    $deviceName2="HAImage2",`
    [string]$enable=$true,`
    [string]$force=$true
    )


Import-Module StarWindX

switch( $Host.UI.PromptForChoice("VSAN Mode Selection",`
        "Set StarWind Maintenance Mode", `
        @("Enable"; "Enable with FORCE"; "Disable"; "Cancel" ),3) )
    {
    0 { $enable=$true
        $force=$false
        Write-Host "Enable selected WITHOUT Force" }
    1 { $enable=$true
        $force=$true
        Write-Host "Enable selected WITH Force" }
    2 { $enable=$false
        Write-Host "Disable selected" }
    3 { Write-Host "Cancelled -- no action taken"
        exit }
    }


Pause

try
{
   Enable-SWXLog

   $server = New-SWServer $addr $port $user $password

   $server.Connect()

#device 1
   $device = Get-Device $server -name $deviceName1
   if( !$device )
   {
      Write-Warning "Device {$deviceName1} not found"
      return
   }

   #params: enable, force
    $device.SwitchMaintenanceMode([bool]::Parse($enable), [bool]::Parse($force))

    Write-Host $deviceName1 "maintenance mode enablement now:" $enable


#device 2
    $device = Get-Device $server -name $deviceName2
   if( !$device )
   {
      Write-Warning "Device {$deviceName2} not found"
      return
   }

   #params: enable, force
    $device.SwitchMaintenanceMode([bool]::Parse($enable), [bool]::Parse($force))

    Write-Host $deviceName2 "maintenance mode enablement now:" $enable

}
catch
{
   Write-Error $_
   exit 1
}
finally
{
#   $server.Disconnect()

    Write-Host "Maintenance mode status may be verified in the StarWind Management Console"


}



Neither is guaranteed bug-free, of course. It would actually be kinda nice if there were a better way to share scripts here.
------------------------
"In theory, theory and practice are the same, but in practice they're not." -- Yogi Berra
wallewek
 
Posts: 70
Joined: Wed Sep 20, 2017 9:13 pm

Re: How to get maintenance status

Postby yaroslav (staff) » Mon Oct 19, 2020 3:21 am

Greetings,

but the domain controllers are virtual guests of the cluster, so can't be reached while bringing up cluster services if the whole cluster is offline.

As DCs, we recommend using 2 local VMs rather than clustered ones. Learn more at https://knowledgebase.starwindsoftware. ... san-usage/.

Devices that report as Synchronized in both PowerShell and the StarWind Management Console are showing 0% synchronized

Can I have the logs please, to confirm that the devices are synchronized? Please collect the logs with StarWind Log Collector (https://knowledgebase.starwindsoftware. ... collector/) and transfer them via Google Disk.

Thank you for the script. I have already requested adding a Maintenance Mode check with PowerShell to StarWindX.
yaroslav (staff)
Staff
 
Posts: 480
Joined: Mon Nov 18, 2019 11:11 am

Re: How to get maintenance status

Postby wallewek » Mon Oct 19, 2020 7:17 pm

Interesting, I do have dual DCs, I'll have to think on that.

I've uploaded the logs as requested and PMed you the link.
------------------------
"In theory, theory and practice are the same, but in practice they're not." -- Yogi Berra
wallewek
 
Posts: 70
Joined: Wed Sep 20, 2017 9:13 pm

Re: How to get maintenance status

Postby wallewek » Wed Oct 21, 2020 5:24 pm

In regards to the PowerShell reporting of synch percentage, I'm beginning to get the feeling that StarWind doesn't bother to report sync percentage accurately unless (a) the devices are not synchronized but (b) synchronization is in progress.

In other words, unless device state is 0 (Active) and Sync Status is 2 (Synchronizing), the sync percent value as reported in PowerShell variable ha_sync_percent should be ignored. A fully synchronized device might report as zero percent synced, but it is irrelevant.

That's pretty much how the StarWind Management Console works: it only reports percentage synchronized while synch is in progress.

You might want to pass that on internally, or confirm.

Oh, and just a quick update -- I have now pulled one DC out of the Microsoft Failover cluster, as you recommended. It makes sense. I might do the other as well, onto the other server.

--- kenw
------------------------
"In theory, theory and practice are the same, but in practice they're not." -- Yogi Berra
wallewek
 
Posts: 70
Joined: Wed Sep 20, 2017 9:13 pm


Return to StarWind Virtual SAN (VSAN) & VSAN Free, StarWind HyperConverged Appliance (HCA) & Storage Appliance (SA)

Who is online

Users browsing this forum: No registered users and 6 guests