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

Fix issue when VHD file mounted #209

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

nyanhp
Copy link

@nyanhp nyanhp commented Feb 6, 2023

Pull Request (PR) description

This PR fixes an issue with Get/Test and the resource VHDFile. If the VHD that files are copied to/from is attached to a running machine, the resource fails and the system is not in the desired state.

This PR skips mounting the VHD if the machine is running. Documentation has been updated to include that change.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the file CHANGELOG.md.
    Entry should say what was changed and how that affects users (if applicable), and
    reference the issue being resolved (if applicable).
  • Resource documentation updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Community Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
  • New/changed code adheres to DSC Community Style Guidelines.

This change is Reviewable

@nyanhp
Copy link
Author

nyanhp commented Feb 6, 2023

Build fails due to dsccommunity/DscResource.DocGenerator#131

@johlju johlju added the needs review The pull request needs a code review. label Feb 6, 2023
@nyanhp
Copy link
Author

nyanhp commented Feb 7, 2023

To whoever owns this module, the build will not work on an Ubuntu worker due to this line:

Add-Type -IgnoreWarnings -ReferencedAssemblies 'C:\Program Files (x86)\Reference Assemblies\Microsoft\WMI\v1.0\Microsoft.Management.Infrastructure.dll' -TypeDefinition @'

The error that occurs with every test is similar to this one:

Executing script /home/jhp/HyperVDsc/tests/Unit/HyperVDsc.Common.Tests.ps1
  [-] Error occurred in test script '/home/jhp/HyperVDsc/tests/Unit/HyperVDsc.Common.Tests.ps1' 0ms
    DriveNotFoundException: Cannot find drive. A drive with the name 'C' does not exist.
    at <ScriptBlock>, /home/jhp/HyperVDsc/tests/Unit/Stubs/Hyper-V.stubs.psm1: line 4
    at <ScriptBlock>, /home/jhp/HyperVDsc/tests/Unit/HyperVDsc.Common.Tests.ps1: line 27
    at <ScriptBlock>, /home/jhp/HyperVDsc/output/RequiredModules/Pester/4.10.1/Pester.psm1: line 1111
    at Invoke-Pester<End>, /home/jhp/HyperVDsc/output/RequiredModules/Pester/4.10.1/Pester.psm1: line 1137
    at <ScriptBlock>, /home/jhp/HyperVDsc/output/RequiredModules/Sampler/0.116.1/tasks/Invoke-Pester.pester.build.ps1: line 351
    at *Task, /home/jhp/HyperVDsc/output/RequiredModules/InvokeBuild/5.10.1/Invoke-Build.ps1: line 590
    at *Task, /home/jhp/HyperVDsc/output/RequiredModules/InvokeBuild/5.10.1/Invoke-Build.ps1: line 562
    at *Task, /home/jhp/HyperVDsc/output/RequiredModules/InvokeBuild/5.10.1/Invoke-Build.ps1: line 562
    at *Task, /home/jhp/HyperVDsc/output/RequiredModules/InvokeBuild/5.10.1/Invoke-Build.ps1: line 562
    at <ScriptBlock><End>, /home/jhp/HyperVDsc/output/RequiredModules/InvokeBuild/5.10.1/Invoke-Build.ps1: line 748
    at <ScriptBlock><Begin>, /home/jhp/HyperVDsc/build.ps1: line 506

Can we use a Windows build worker for this repository?

@nyanhp
Copy link
Author

nyanhp commented Feb 22, 2023

@johlju do you know who maintains this module? I am not able to get the build to work. It fails while publishing the test results to codecov.io

@johlju
Copy link
Member

johlju commented Feb 25, 2023

Unfortunatly I don't think there is any active maintainer on this module any longer.

@johlju
Copy link
Member

johlju commented Feb 25, 2023

I have a look see if I can se anything.

@johlju
Copy link
Member

johlju commented Feb 25, 2023

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@johlju
Copy link
Member

johlju commented Feb 25, 2023

Please revert that change above and it should work. If not then we have to look for an issue somewhere else, because that is how all pipelines looks.

@johlju
Copy link
Member

johlju commented Feb 25, 2023

@nyanhp it seems you renamed the folder DSC_VHD to DSC_Vhd but the rename is not part of the change. Becuase of that this PR suggest to add new files instead of changing the existing resource.

@nyanhp
Copy link
Author

nyanhp commented Apr 17, 2023

@johlju I've reverted the change to the build worker image and the VHD casing. But even with the correct casing, the original issue remains:

Exception: Failed to import classes from file
/home/vsts/work/1/s/source/DSCResources/DSC_VHD/DSC_VHD.schema.mof. Error
Exception calling "ImportClasses" with "3" argument(s): "Unable to load shared
library 'libmi' or one of its dependencies. In order to help diagnose loading
problems, consider setting the LD_DEBUG environment variable: liblibmi: cannot
open shared object file: No such file or directory"

@johlju
Copy link
Member

johlju commented Apr 17, 2023

Charge the build stage and test stages (unit and integration if it exist) to use windows-latest as the VM image instead of Ubuntu.

@johlju
Copy link
Member

johlju commented Apr 17, 2023

In azure-pipelines.yml

@johlju
Copy link
Member

johlju commented Apr 17, 2023

Not sure why the build fails now, something is off with the pipeline files. I don't recognize the error. Have no time to find the cause. Ping me in a week or so and I can help dig.

nyanhp added a commit to nyanhp/HyperVDsc that referenced this pull request Apr 18, 2023
@nyanhp
Copy link
Author

nyanhp commented Apr 18, 2023

Thanks for your effort @johlju , I assume the renaming VHD to Vhd was the issue. I can see that all tests were passed, only the code coverage could not be reported.

This reverts commit 4346d6f.
@codecov
Copy link

codecov bot commented Apr 21, 2023

Codecov Report

Merging #209 (968fd4b) into main (6c0e583) will increase coverage by 0%.
The diff coverage is 92%.

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #209   +/-   ##
===================================
  Coverage    83%    83%           
===================================
  Files        11     11           
  Lines      1441   1497   +56     
===================================
+ Hits       1203   1257   +54     
- Misses      238    240    +2     
Impacted Files Coverage Δ
...ces/DSC_VhdFileDirectory/DSC_VhdFileDirectory.psm1 90% <92%> (+1%) ⬆️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review The pull request needs a code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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