dsccommunity / StorageDsc

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

OpticalDiskDriveLetter: If optical drive is not present, the behaviour of the ressource should change if "Ensure" is set to "Absent" #194

Closed AlexGitHubAcc closed 4 years ago

AlexGitHubAcc commented 5 years ago

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

Sometimes you get an optical drive in a Vm deployed to Azure and sometimes not. That's why I tkink it may be handy to make sure there's no optical drive through the usage of the 'OpticalDiskDriveLetter' resource.

If the VM does not use an optical drive and the 'Ensure' parameter is set to 'Absent', the resource returns an error, which will also stop the whole DSC configuration run with an error result.

Verbose logs showing the problem

Event viewer:

MIResult: 1
Error Message: PowerShell DSC resource MSFT_OpticalDiskDriveLetter  failed to execute Test-TargetResource functionality with error message: The optical disk 1 could not be found in the system, so this resource has nothing to do. This resource does not change the drive letter of mounted ISOs.
Parameter name: DiskId 
Message ID: ProviderOperationExecutionFailure
Error Category: 7
Error Code: 1
Error Type: MI

Job {22C5A49F-345F-11E9-A811-000D3A25D8DA} : 
This event indicates that failure happens when LCM is processing the configuration. Error Id is 0x1. Error Detail is The SendConfigurationApply function did not succeed.. Resource Id is [OpticalDiskDriveLetter]RemoveFirstOpticalDiskDriveLetter and Source Info is ::49::9::OpticalDiskDriveLetter. Error Message is PowerShell DSC resource MSFT_OpticalDiskDriveLetter  failed to execute Test-TargetResource functionality with error message: The optical disk 1 could not be found in the system, so this resource has nothing to do. This resource does not change the drive letter of mounted ISOs.
Parameter name: DiskId .

Job {22C5A49F-345F-11E9-A811-000D3A25D8DA} : 
Message The optical disk 1 could not be found in the system, so this resource has nothing to do. This resource does not change the drive letter of mounted ISOs.
Parameter name: DiskId 
HResult -2146233087 
StackTrack    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.ResourceProviderAdapter.ExecuteCommand(PowerShell powerShell, ResourceModuleInfo resInfo, String operationCmd, List`1 acceptedProperties, CimInstance nonResourcePropeties, CimInstance resourceConfiguration, LCMDebugMode debugMode, PSInvocationSettings pSInvocationSettings, UInt32& resultStatusHandle, Collection`1& result, ErrorRecord& errorRecord, PSModuleInfo localRunSpaceModuleInfo)

DscConfigurationLog (Get-AzureRmVMDscExtensionStatus)

[ERROR] PowerShell DSC resource MSFT_OpticalDiskDriveLetter  failed to execute Test-TargetResource functionality with error message: The optical disk 1 could not be found in the system, so this resource has nothing to do. This resource does not change the drive letter of mounted ISOs.
Parameter name: DiskId
[ERROR] The SendConfigurationApply function did not succeed. LCM failed to start desired state configuration manually.

Suggested solution to the issue

The solution shoud handle this scenrio in a more error resistant way, e.g. checking the information in the 'Ensure' parameter before firing an exception and thus stop the whole DSC configuration run.

The DSC configuration that is used to reproduce the issue (as detailed as possible)

OpticalDiskDriveLetter RemoveFirstOpticalDiskDriveLetter
{
    DiskId      = 1
    DriveLetter = 'X' # This value is ignored
    Ensure      = 'Absent'
}

The operating system the target node is running

OsName : Microsoft Windows Server 2016 Datacenter OsOperatingSystemSKU : DatacenterServerEdition OsArchitecture : 64-bit WindowsBuildLabEx : 14393.2791.amd64fre.rs1_release.190205-1511 OsLanguage : en-US OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

PSVersion 5.1.14393.2791 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.14393.2791 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Version of the DSC module that was used ('dev' if using current dev branch)

Manifest 4.4.0.0 StorageDsc

PlagueHO commented 5 years ago

Thanks for raising this @AlexGitHubAcc - that sounds like a good idea. We'll leave the enhancement open for community feedback and then look at getting onto it.

ricohomewood commented 4 years ago

This is still an annoying issue in the Azure world. As some of the VM series Hyper-V clusters in Microsoft datacenters have optical disks and some don't.

@PlagueHO @SteveL-MSFT Is there any movement on trying to fix this bug?

PlagueHO commented 4 years ago

Hi @ricohomewood. I'll work on this once I've completed the update to the new pipeline. Without that we cant release any changes. I'm hoping to get this finished this week. Sorry about the delay.

ricohomewood commented 4 years ago

Hi @PlagueHO any update on the above at all? Am i right in thinking the new pipeline is now in place?

PlagueHO commented 4 years ago

Thank you for reminding me @ricohomewood !