Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disk resource trying to resize the partition even if it was not told to do so. #246

Open
jojiklmts opened this issue Aug 21, 2020 · 4 comments
Assignees
Labels
enhancement The issue is an enhancement request. in progress The issue is being actively worked on by someone.

Comments

@jojiklmts
Copy link

I have this very simple disk config. Just trying to set a label.

Disk CVolume
        {
             DiskId = ‘0’
             DriveLetter = ‘C’
             FSLabel = ‘System’
        }

However when the config is executed, DSC is trying to resize the disk for some reason. I am not telling it to touch the disk size. See below WARNING line.

VERBOSE: [server]: LCM: [ Start Resource ] [[Disk]CVolume]
VERBOSE: [server]: LCM: [ Start Test ] [[Disk]CVolume]
VERBOSE: [server]: [[Disk]CVolume] Test-TargetResource: Testing disk with Number ‘0’ status for drive letter ‘C’.
VERBOSE: [server]: [[Disk]CVolume] Test-TargetResource: Checking if disk with Number ‘0’ is initialized.
VERBOSE: [server]: [[Disk]CVolume] Perform operation ‘Query CimInstances’ with following parameters, ”queryExpression’ = SELECT BlockSize from Win32_Volume WHERE DriveLetter = ‘C:’,’queryDialect’ = WQL,’namespaceName’ = root\cimv2′.
VERBOSE: [server]: [[Disk]CVolume] Operation ‘Query CimInstances’ complete.
VERBOSE: [server]: [[Disk]CVolume] Test-TargetResource: Volume assigned to drive C label ” does not match expected label ‘System’.
VERBOSE: [server]: LCM: [ End Test ] [[Disk]CVolume] in 4.3440 seconds.
VERBOSE: [server]: LCM: [ Start Set ] [[Disk]CVolume]
VERBOSE: [server]: [[Disk]CVolume] Set-TargetResource: Setting disk with Number ‘0’ status for drive letter ‘C’.
VERBOSE: [server]: [[Disk]CVolume] Set-TargetResource: Checking disk with Number ‘0’ partition style.
VERBOSE: [server]: [[Disk]CVolume] Set-TargetResource: Disk with Number ‘0’ is already initialized with ‘GPT’.
VERBOSE: [server]: [[Disk]CVolume] Set-TargetResource: Partition ‘4’ is already assigned as drive C.
WARNING: [server]: [[Disk]CVolume] Set-TargetResource: Skipping resize of C from 106819485696 to 106820517376. AllowDestructive is not set to $true.
VERBOSE: [server]: LCM: [ End Set ] [[Disk]CVolume] in 3.0470 seconds.
VERBOSE: [server]: LCM: [ End Resource ] [[Disk]CVolume]

I talked with Daniel Scott-Raynsford and this seems to be the root cause:
"The challenge there is that the resource is designed so that if you don't specify a size for the partition it assumes you want to make the partition/volume consume all remaining space on the disk.
We could potentially implement a flag to force ignoring the size of the partition - if the partition already exists - that would resolve the problem"

@PlagueHO PlagueHO added enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community. labels Aug 21, 2020
@PlagueHO
Copy link
Member

Suggest parameter name IgnoreSizeIfPartitionExists - this should suppress the size test in Test-TargetResource:
https://github.com/dsccommunity/StorageDsc/blob/master/source/DSCResources/DSC_Disk/DSC_Disk.psm1#L831

A notification message should be included to indicate the size test was suppressed.

This should be enabled in DiskAccessPath once destructive changes are allowed - but as this feature has not been ported to that resource then we don't need to do this now.

@PlagueHO PlagueHO self-assigned this Aug 28, 2020
@PlagueHO PlagueHO added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Aug 28, 2020
@PlagueHO
Copy link
Member

@jojiklmts - I'm just working on this, but can you confirm something for me:
What was the label of C drive before and after applying the configuration? The logs you're seeing don't seem to match up with what I'd expect to see.

I would have expected to see:

  1. In the Test-TargetResource: the partition size was reported to be different.
  2. In the Set-TargetResource: The drive label should have been reported to be set to 'System'.

Neither message is shown, so this makes me think something else is wrong.

The reason Set is being run at all is because the Disk label mismatches - not because of the Disk size difference.

@jojiklmts
Copy link
Author

So I removed now the "System" Label on purpose to demonstrate this.

PS C:\Windows\system32> Get-Volume -DriveLetter c

DriveLetter FileSystemLabel FileSystem DriveType HealthStatus SizeRemaining     Size
----------- --------------- ---------- --------- ------------ -------------     ----
C                           NTFS       Fixed     Healthy           85.08 GB 99.48 GB

Now I run the DSC config and I get the same as I shown before. It correctly identifies that the Label is not set correctly but before it attempts to correct it, it will stop because it is also trying to resize the volume (which it was not told to do) and it will halt because destructive change is not allowed:

VERBOSE: [S021MD9C3]: LCM:  [ Start  Resource ]  [[Disk]CVolume]
VERBOSE: [S021MD9C3]: LCM:  [ Start  Test     ]  [[Disk]CVolume]
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Test-TargetResource: Testing disk with Number '0' status for drive letter 'C'.
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Test-TargetResource: Checking if disk with Number '0' is initialized.
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Perform operation 'Query CimInstances' with following parameters, ''queryExpression' = SELECT BlockSize from Win32_Volume WHERE DriveLetter = 'C:','queryDialect' = WQL,'namespaceName' = root\cimv2'.
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Operation 'Query CimInstances' complete.
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Test-TargetResource: Volume assigned to drive C label '' does not match expected label 'System'.
VERBOSE: [S021MD9C3]: LCM:  [ End    Test     ]  [[Disk]CVolume]  in 4.4700 seconds.
VERBOSE: [S021MD9C3]: LCM:  [ Start  Set      ]  [[Disk]CVolume]
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Set-TargetResource: Setting disk with Number '0' status for drive letter 'C'.
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Set-TargetResource: Checking disk with Number '0' partition style.
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Set-TargetResource: Disk with Number '0' is already initialized with 'GPT'.
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Set-TargetResource: Partition '4' is already assigned as drive C.
WARNING: [S021MD9C3]:                            [[Disk]CVolume] Set-TargetResource: Skipping resize of C from 106819485696 to 106820517376. AllowDestructive is not
set to $true.
VERBOSE: [S021MD9C3]: LCM:  [ End    Set      ]  [[Disk]CVolume]  in 3.5320 seconds.
VERBOSE: [S021MD9C3]: LCM:  [ End    Resource ]  [[Disk]CVolume]

Now I set the Label manually to be "System" as can be seen below:

PS C:\Windows\system32> Get-Volume -DriveLetter c

DriveLetter FileSystemLabel FileSystem DriveType HealthStatus SizeRemaining     Size
----------- --------------- ---------- --------- ------------ -------------     ----
C           System          NTFS       Fixed     Healthy           85.07 GB 99.48 GB

And finally this is what DSC execution looks like when the Label is already set as "System":

VERBOSE: [S021MD9C3]: LCM:  [ Start  Resource ]  [[Disk]CVolume]
VERBOSE: [S021MD9C3]: LCM:  [ Start  Test     ]  [[Disk]CVolume]
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Test-TargetResource: Testing disk with Number '0' status for drive letter 'C'.
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Test-TargetResource: Checking if disk with Number '0' is initialized.
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Perform operation 'Query CimInstances' with following parameters, ''queryExpression' = SELECT BlockSize from Win32_Volume WHERE DriveLetter = 'C:','queryDialect' = WQL,'namespaceName' = root\cimv2'.
VERBOSE: [S021MD9C3]:                            [[Disk]CVolume] Operation 'Query CimInstances' complete.
VERBOSE: [S021MD9C3]: LCM:  [ End    Test     ]  [[Disk]CVolume]  in 4.4270 seconds.
VERBOSE: [S021MD9C3]: LCM:  [ Skip   Set      ]  [[Disk]CVolume]
VERBOSE: [S021MD9C3]: LCM:  [ End    Resource ]  [[Disk]CVolume]

@jgriffiths014
Copy link

Hi, has this - or #248 been fixed yet? we're still having this issue on VMSS and the ex-colleague of mine ianwalkeruk raised this 2 years ago.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request. in progress The issue is being actively worked on by someone.
Projects
None yet
Development

No branches or pull requests

3 participants