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

VHDFile: After initial push, resource can never be in desired state if disk is attached to VM #207

Open
nyanhp opened this issue Jan 17, 2023 · 0 comments · May be fixed by #209
Open

VHDFile: After initial push, resource can never be in desired state if disk is attached to VM #207

nyanhp opened this issue Jan 17, 2023 · 0 comments · May be fixed by #209

Comments

@nyanhp
Copy link

nyanhp commented Jan 17, 2023

Problem description

Consistency checks fail, if disk is attached to a running VM. Only the initial push works flawlessly. Afterwards, the nodes will never achive the desired state unless the VMs are stopped every time...

Verbose logs

VERBOSE: [flamberge]: LCM:  [ Start  Resource ]  [[VhdFile]SQL002osdiskmof]
VERBOSE: [flamberge]: LCM:  [ Start  Test     ]  [[VhdFile]SQL002osdiskmof]
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Mounting Failed. Attempting to
dismount and mount it back
The path "C:\ClusterStorage\SU1_Volume\SQL002\SQL002_OS.vhdx" is not the path to a mounted virtual hard
disk file.
    + CategoryInfo          : InvalidArgument: (:) [], CimException
    + FullyQualifiedErrorId : InvalidParameter,Microsoft.Vhd.PowerShell.Cmdlets.DismountVHD
    + PSComputerName        : localhost

VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Alias
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] C
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Cert
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] D
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] E
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Env
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] F
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Function
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] HKCU
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] HKLM
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Variable
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] WSMan
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] :\
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] SourcePath =>
E:\ISO\RequiredModules\*
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Type => Directory
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Ensure => True
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Content =>
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] DestinationPath => Program
Files\WindowsPowerShell\Modules
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Force => False
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Attributes =>
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Recurse => True
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Testing the file with relative VHD
destination Program Files\WindowsPowerShell\Modules
VERBOSE: [flamberge]:                            [[VhdFile]SQL002osdiskmof] Test returned False
VERBOSE: [flamberge]: LCM:  [ End    Test     ]  [[VhdFile]SQL002osdiskmof]  in 0.2030 seconds.
The PowerShell DSC resource '[VhdFile]SQL002osdiskmof' with SourceInfo '::49::13::VhdFile' threw one or more
non-terminating errors while running the Test-TargetResource functionality. These errors are logged to the ETW channel
called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost

DSC configuration

configuration disk
{
    import-dscresource -modulename hypervdsc -ModuleVersion 4.0.0
    node localhost
    {
        VhdFile "SQL002osdiskmof"
        {
            VhdPath       = 'C:\ClusterStorage\SU1_Volume\SQL002\SQL002_OS.vhdx'
            FileDirectory = @(DSC_FileDirectory
                {
                    SourcePath      = 'C:\Program Files\WindowsPowerShell\Modules'
                    DestinationPath = 'Program Files\WindowsPowerShell\Modules'
                    Recurse         = $true
                    Type            = 'Directory'
                    Ensure          = 'Present'
                    Force           = $true
                }
            )
        }
    }
}

disk
Start-DscConfiguration -path ./disk -wait -Verbose -force

Suggested solution

Unclear. If I understood the resource properly, I would suggest skipping the Set method entirely if the VHD has been attached to a (running) VM.
Reasoning: If the machine is already running, even if the disk is already attached, we have to assume that there should be no additional file copies, as the machine is now owned by someone else.

Operating system the target node is running

Server 2016

PowerShell version and build the target node is running

5.1

HyperVDsc version

4.0.0
@nyanhp nyanhp linked a pull request Feb 6, 2023 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant