dsccommunity / StorageDsc

DSC resource module is used to manage storage on Windows Servers.
https://dsccommunity.org
MIT License
71 stars 52 forks source link

Unexpected Volume Size does not change InDesiredState value #75

Closed ed-vazquez closed 7 years ago

ed-vazquez commented 7 years ago

Below are 2 config blocks.

Initial_DataDisk sets a volume on a disk to 200MB. DifferentSizeVolume_DataDisk expects a volume size of 300MB. Test-DscConfiguration inDesiredState = True although there is a mismatch in volume sizes.

Configuration Initial_DataDisk
{

    Import-DscResource -ModuleName xStorage

    Node localhost
    {
        xWaitforDisk Disk1
        {
            DiskNumber = 1
            RetryIntervalSec = 60
            RetryCount = 60
        }

        xDisk XVolume {
            DiskNumber = 1
            DriveLetter = 'Z'
            Size = 200MB
        }
    }
}

Configuration DifferentSizeVolume_DataDisk
{

    Import-DscResource -ModuleName xStorage

    Node localhost
    {
        xWaitforDisk Disk1
        {
            DiskNumber = 1
            RetryIntervalSec = 60
            RetryCount = 60
        }

        xDisk XVolume {
            DiskNumber = 1
            DriveLetter = 'Z'
            Size = 300MB
        }
    }
}

#write mofs
Initial_DataDisk -OutputPath C:\Initial_DataDisk 
DifferentSizeVolume_DataDisk -OutputPath C:\DifferentSizeVolume_DataDisk 

#DSC Volume w/Initial_DataDisk
Start-DscConfiguration -Path C:\Initial_DataDisk -Wait -Force

#Test volume with different volume size
Test-DscConfiguration -Path C:\DifferentSizeVolume_DataDisk -Verbose

<#
    Test Volume w/Different size Volume
    Expect desired state to be false because volume size does not match
    Verbose seems to identify mismatch but InDesiredState value is True 

VM Disk size = 1GB

InDesiredState             : True
ResourcesInDesiredState    : {[xWaitForDisk]Disk1, [xDisk]XVolume}
ResourcesNotInDesiredState : 
ReturnValue                : 0
PSComputerName             : localhost

VERBOSE: [WIN-HOST]:                            [[xDisk]XVolume] Test-TargetResource: Drive Z size 209715200 does not match expected size 3145
72800.

#>
ed-vazquez commented 7 years ago

Issue may that test-resource does not return false for a mismatch like the other tests.

# Drive size
    if ($Size)
    {
        if ($partition.Size -ne $Size)
        {
            # The partition size mismatches but can't be changed (yet)
            Write-Verbose -Message ( @(
                    "$($MyInvocation.MyCommand): "
                    $($LocalizedData.DriveSizeMismatchMessage `
                        -f $DriveLetter,$Partition.Size,$Size)
                ) -join '' )
        } # if
    } # if
PlagueHO commented 7 years ago

Hi @VazquezTech - Thank you for reporting this. You are quite correct. This is a known limitation of the resource. This has been on my todo list but I haven't had time to look into it.

This is actually a duplicate of issue #11. It requires the destructive switch (is discussed in #50) to be implemented to allow destructive changes to be made to a disk (in this case resizing the partition).

We choose to return $true when a size mismatch occurs to prevent the Set-TargetResource firing when we can't actually do anything to resolve the size mismatch (yet).

But as this is a duplicate of issue #11, can we close this issue and raise and further discussion in that one?

ed-vazquez commented 7 years ago

Hi Daniel,

Thank you for the prompt response. Please close issue.

On Thu, Jan 12, 2017 at 6:21 AM Eduardo Vazquez evazquez@vazqueztech.com wrote:

On Thu, Jan 12, 2017 at 12:56 AM Daniel Scott-Raynsford < notifications@github.com> wrote:

Hi @VazquezTech https://github.com/VazquezTech - Thank you for reporting this. You are quite correct. This is a known limitation of the resource. This has been on my todo list but I haven't had time to look into it.

This is actually a duplicate of issue #11 https://github.com/PowerShell/xStorage/issues/11. It requires the destructive switch (is discussed in #50 https://github.com/PowerShell/xStorage/issues/50) to be implemented to allow destructive changes to be made to a disk (in this case resizing the partition).

We choose to return $true when a size mismatch occurs to prevent the Set-TargetResource firing when we can't actually do anything to resolve the size mismatch (yet).

But as this is a duplicate of issue #11 https://github.com/PowerShell/xStorage/issues/11, can we close this issue and raise and further discussion in that one?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PowerShell/xStorage/issues/75#issuecomment-272082862, or mute the thread https://github.com/notifications/unsubscribe-auth/ABdc1o9iQ5nJWhHab1XKFGuy7YQ5pSrAks5rRcBwgaJpZM4LhFq6 .

PlagueHO commented 7 years ago

Thanks @VazquezTech - I'll try and get to the issue #11 when I get time (seem to be very short of it these days).