dsccommunity / FailoverClusterDsc

This module contains DSC resources for deployment and configuration of Windows Server Failover Cluster.
MIT License
60 stars 54 forks source link

ClusterDisk: Should check if disk is actually available for use #200

Open kungfoome opened 5 years ago

kungfoome commented 5 years ago

Problem

https://github.com/PowerShell/xFailOverCluster/blob/c5702cac81a46a844c7d903c56be7ae8a90ad9f0/DSCResources/MSFT_xClusterDisk/MSFT_xClusterDisk.psm1#L90

Because this is using availabledisk and then just adding them, it's assuming the cluster can use the disk in the next procedure. The disk does not exist so it errors out incorrectly

The property 'Name' cannot be found on this object. Verify that the property exists and can be set.

Possible Solution:

Check if the disk actually exists

$clusterdDisk = Get-ClusterAvailableDisk | Where-Object -FilterScript {
    $_.Number -eq $Number
} 

if($clusterdDisk)
{
    $clusterdDisk | Add-ClusterDisk
}
else
{
    throw error
}
johlju commented 5 years ago

It should definitely return the correct error as per your suggestion.

Curious though, why does it not have the disk available? Should we have a WaitForClusterDisk resource? 🤔

kungfoome commented 5 years ago

Essentially that's correct. Basically, the cluster is created already, the disk was added over iscsi, but the other node didn't have the disk yet, so it won't allow you to add the disk until that disk is shared between the two.

If I go to node2 and refresh the iscsi target, then it works afterwards

johlju commented 5 years ago

Ah, I understand. So Get-ClusterAvailableDisk does not see the disks until they exist on both nodes? I was wondering if it would say Add-ClusterDisk -ErrorAction ‘Stop’ It would it throw the correct error, but won’t work if the disk aren’t even visible yet. So I like your suggested solution.

kungfoome commented 5 years ago

Correct. Just comes back empty