dsccommunity / StorageDsc

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

Disk: Inexact UniqueID matching #247

Open bozho opened 4 years ago

bozho commented 4 years ago

Details of the scenario you tried and the problem that is occurring

It seems that as of recently, AWS doesn't guarantee disk ordering in Windows VMs. Previously, the order was controlled by volume device names (xvd[a-z]) and was stable across VM reboots.

Not having stable disk ordering makes disk initialisation and drive letter assignment impossible.

AWS does map EBS volume ID to UniqueId disk property. UniqueId is formatted as: <volume id without the dash>0001Amazon Elastic Block Store 1D0F

This allows us to use Unique ID to initialise disks and assign drive letters. However, it is unknown how stable ID format is going to be in the future, but it is safe to assume it will always reference EBS volume ID in some form.

Suggested solution to the issue

Introduce an additional DiskIdType: UniqueIdPattern, which would allow pattern matching for disk serial numbers. The resource would throw an error in case of multiple matches.

Happy to implement and submit a PR.

PlagueHO commented 4 years ago

Hi @bozho,

Do you have an example of how the resource configuration would look using this? E.g.

Disk AWSDisk {
    DiskIdType = 'UniqueIdPattern'
    DiskId = .....
}
bozho commented 4 years ago

Ah, yes. Apologies - was writing this up yesterday after losing the entire day trying to work around the problem :-)

A sample resource configuration would look something like:

Disk AWSDisk {
    DiskIdType = 'UniqueIdPattern'
    DiskId = 'vol0fcccef34ab4dff0a.*'
    DriveLetter = 'G'
}

I think it makes sense to use regex pattern matching here. I have a limited number of machines to test, but UniqueId disk property string seems to always contain disk serial number in certain format (for physical disks). For example, on my laptop (Win 10 Pro), both disks' UniqueId is in the format eui.<serial number>.

At the moment, I only have access to AWS and Proxmox VMs and both of them format UniqueId to correlate to storage volumes (Proxmox's UniqueId string contains disk number and VM name). I think it would make sense to assume that hypervisors/cloud providers will have some sort of correlation between a volume and VM's disk UniqueId

PlagueHO commented 4 years ago

Cool - yep, I think this looks possible. We might need to get the resource to stop though if the RegEx returns more than one disk. Either with a Warning or most likely we'd want an error here.

bozho commented 4 years ago

I was thinking an error. I'll get on implementing this, hopefully some time during this week.

PlagueHO commented 4 years ago

Cool - thanks @bozho . I'll mark it as In Progress.

ianwalkeruk commented 3 years ago

Hi @bozho

Have you tried using the DiskIdType of Location? I added that last year after having a similar problem with Windows VMs in Azure?

I don't want to stop you from implementing a nice pattern matching type as well, just curious if you've got the time to test the Location type on AWS?