Closed Zuldan closed 7 years ago
Hi @Zuldan - thanks for the detailed info. I'm just trying to replicate this now.
Can you confirm the OS Version you're installing onto and also if possible post the config? I'll continue to look into this now though.
@PlagueHO thank you for looking at this so quickly. I created a second VM just to make sure it wasn't a once off issue but got the same problem.
OS is 2012 R2 (latest Windows Updates and running WMF 5.1). The VM has 16 disks in total. I'll do my best to get you the config tonight as soon as I get access to my laptop.
I really hope this isn't just my environment and I'm wasting your time.
@Zuldan - definitely want to get this one sorted. I can see some things that aren't right in your logs, but I'm just trying to figure out how they got to that state.
I'm testing on a Windows Server 2016 Hyper-V VM at the moment and using the following config to test:
Configuration Example
{
Import-DSCResource -ModuleName xStorage
node $AllNodes.NodeName
{
xWaitforDisk Disk1
{
DiskId = 1
RetryIntervalSec = 60
RetryCount = 60
}
xDiskAccessPath DataVolume
{
DiskId = 1
AccessPath = 'c:\SQLData'
DependsOn = '[xWaitForDisk]Disk1'
}
xWaitforDisk Disk2
{
DiskId = 2
RetryIntervalSec = 60
RetryCount = 60
}
xDiskAccessPath LogVolume
{
DiskId = 2
AccessPath = 'c:\SQLLog'
DependsOn = '[xWaitForDisk]Disk2'
}
}
}
$configData = @{
AllNodes = @(
@{
NodeName = 'SA-DC1'
PsDscAllowPlainTextPassword = $true
}
)
}
Example -OutputPath $ENV:Temp -ConfigurationData $configData
Start-DscConfiguration -Path $ENV:Temp -ComputerName 'SA-DC1' -Wait -Verbose -Force
Both Disk1 and Disk2 were completely uninitialized and were offline. They both resulted in the disks being onlined, partitioned, formatted and mounted to the folders as expected:
So I'm not sure what exactly is going wrong. But I'll continue to investigate.
Hi @Zuldan - are you able to describe the state your disks/partitions were before running your configs? I'm wondering if the disks being partitioned but not mounted is the problem?
The reason I'm thinking this is that I'm not seeing any info on the disks being initialized or bought online which is what I'd expect to see with a clean disk. I'm also seeing strange partition info. So I'm just trying some experiments with disks in different states, but any info you can provide will be very helpful!
All disks were completely uninitialized and were offline. The other info I have is disk 4 is being configured first. I guess the main difference between our environments is you have Hyper-V and I have ESXi. I wouldn't expect Powershell cmdlets to behave differently though.
I've almost got the kids in bed so more info should arrive soon.
Hi @Zuldan - I've managed to replicate the problem and it seems to only occur on Windows Server 2012 R2. I've been testing on Windows 10 and Windows Server 2016. The AppVeyor CI process runs Windows Server 2016 as well.
So now I can replicate it I should be able to fix it, which is good news.
I did identify another problem as well which I'll log and repair in a separate issue.
I think this problem is also the same one as this one: https://github.com/PowerShell/xStorage/issues/85
Fantastic @PlagueHO I was about to spin up another VM to try replicate the problem again. I thought the resource might be seeing something unexpected. Notice the 'System.Object[]' in the Verbose message.
Set-TargetResource: Partition 'System.Object[]' is already assigned to access path 'C:\MountPoint\SQLDATA01\'.
@Zuldan - I've figured out the problem:
In Windows Server 2012 R2 the Add-PartitionAccessPath
cmdlet doesn't support having a Disk object piped to it, whereas this is supported in Windows Server 2016 and Windows 10.
E.g. This works in Windows Server 2016, but not Windows Sever 2012 R2:
$disk | Add-PartitionAccessPath `
-AccessPath $AccessPath `
-PartitionNumber $partition.PartitionNumber
So I need to change it to:
Add-PartitionAccessPath `
-AccessPath $AccessPath `
-DiskNumber $disk.Number `
-PartitionNumber $partition.PartitionNumber
So I'll make the changes now and submit the PR tonight. So if you're feeling adventurous tomorrow you'll be able to try my branch. I did find one other problem that can occur (as I mentioned earlier) that I'd like to also fix, but I'll fix it in a separate PR.
Fantastic! good work. I'll try it tomorrow morning and report back. Really appreciate you looking at this so quickly.
I'm guessing you'll also need to do the same for UniqueId.
Add-PartitionAccessPath `
-AccessPath $AccessPath `
-DiskNumber $disk.UniqueId `
-PartitionNumber $partition.PartitionNumber
Actually ignore the above code. That doesn't make sense. I'm sure you know what I mean ;P
@Zuldan - haha yep - I know exactly what you mean. I don't need to worry about the UniqueId vs Number thing though because the $Disk object already contains the Disk that was retrieved using the required identifier.
I also figured out why these tests never caught the problem: The integration tests can't run on AppVeyor because they require Hyper-V so that a VHDX can be created and mounted. This is because I need the New-VHD
cmdlet which is only available in Hyper-V (which is a pain because it really shouldn't require this - as you can still mount VHDs as disks without Hyper-V). You can't of course enable Hyper-V on AppVeyor - and all my testing is being done on Windows Server 2016.
So I'm going to try and figure out a way of creating VHD files without Hyper-V.
@Zuldan - here is the new fixed version in my repo: https://github.com/PlagueHO/xStorage/tree/Issue-102
I'm going to try and get DISKPART to create the VHD to use for testing in AppVeyor which will allow more effective automated testing. So I won't submit this PR until I can get that working- so that will be tomorrow night.
Thanks for your patience and help!
@PlagueHO I can confirm it's working fine now on 2012 R2. Many thanks again! You are owed many beers.
@Zuldan - always a pleasure - and I did write the code that original broke it :grin: But it happens and is just a chance for me to implement better automated tests! I actually have come up with a way I can run the tests in AppVeyor against WS2012R2 so that it should be tested every time.
When use xDiskAccessPath I get the error "One or more parameter values passed to the method were invalid" and "The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input." I had previously tested 2.9.0.0 and 3.1.0.0 and found both version working but I've realized today that they were being used lab servers that already had Mount Points created. Today, I created a production server (disks offline and uninitialized) and the above errors appeared with both 2.9.0.0 and 3.1.0.0. The issue exists with both disk types, DiskNumber and UniqueId.
First consistency check
Second consistency check (not changing anything)
Third consistency check (manually used Disk Management to map the mount points to various directories in C:\MountPoint)
Forth consistency check (100% compliant)