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

xAccessPath: Access Path not found - Fixes #121 #126

Closed
wants to merge 11 commits into from

Conversation

positivism1
Copy link

@positivism1 positivism1 commented Nov 13, 2017

Pull Request (PR) description

This Pull Request (PR) fixes the following issues:
Fixes #121

Task list:

  • Change details added to Unreleased section of CHANGELOG.md?
  • Added/updated documentation, comment-based help and descriptions in .schema.mof files where appropriate?
  • Examples appropriately updated?
  • New/changed code adheres to Style Guidelines?
  • Unit and (optional) Integration tests created/updated where possible?

This change is Reviewable

@msftclas
Copy link

msftclas commented Nov 13, 2017

CLA assistant check
All CLA requirements met.

@codecov-io
Copy link

codecov-io commented Nov 13, 2017

Codecov Report

Merging #126 into dev will decrease coverage by <1%.
The diff coverage is 55%.

Impacted file tree graph

@@        Coverage Diff         @@
##           dev   #126   +/-   ##
==================================
- Coverage   94%    94%   -1%     
==================================
  Files        5      5           
  Lines      671    680    +9     
==================================
+ Hits       636    641    +5     
- Misses      35     39    +4

@PlagueHO PlagueHO added the needs review The pull request needs a code review. label Nov 17, 2017
@PlagueHO
Copy link
Member

Thank you very much @positivism1 for submitting this! It is greatly appreciated and a really awesome job. Review comments and changes are completely normal and expected part of the process 🍰 We all get them (any of the people who have reviewed my code will agree 😉 ). Keep up the awesome work!

If you make the changes below and just push back to your branch then hit the Reviewable button on your PR you will be able to click Done on any of the changes you've made and I can continue the review.


Reviewed 3 of 3 files at r1.
Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed.


CHANGELOG.md, line 11 at r1 (raw file):

- xDiskAccessPath:
  - Added support for Guid Disk Id type - See [Issue 104](https://github.com/PowerShell/xStorage/issues/104).
  - Added check for PSDrive existance  to solve bug - See [Issue 121](https://github.com/PowerShell/xStorage/issues/121).

Please remove extra space between existance and to.

Also existance should be spelled existence. 😁


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1, line 532 at r1 (raw file):

    )

  Try 

I think this code actually needs to be moved into the Set-TargetResource rather than in Test-TargetResource. You'd want to add it just after the volume has been formatted. The reason is that the first time Test-TargetResource is hit and the disk isn't already assigned then Get-PSDrive will fire twice and then Set-TargetResource will create the new drive. But Get-PSDrive needs to fire after the drive has been created but before you try and use it in one of your following steps.

So, I reckon this code needs to go in somewhere around here:
https://github.com/PowerShell/xStorage/blob/dev/Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1#L466

Convert to lower case T in Try.

Also, the alignment seems a bit off on this code block and there are a few extra spaces at the end of these lines.

The easiest way to fix it is to use Visual Studio Code format document feature. I wrote a quick blog post showing how to use it:
https://dscottraynsford.wordpress.com/2017/11/18/auto-formatting-powershell-in-visual-studio-code/


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1, line 534 at r1 (raw file):

  Try 
    {
          $AccessPathDisk = $AccessPath.split(":")[0]

Please use lower case for first letter of local variables. E.g.

$AccessPathDisk = $AccessPath.split(":")[0]

Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1, line 539 at r1 (raw file):

            $($localizedData.TestingPSDriveMessage -f $AccessPathDisk,$AccessPath)
        ) -join '' )
         $TestDrive = Get-PSDrive $AccessPathDisk -ErrorAction Stop

You could assign this to $null because the result will never be used. Visual Studio Code will underline this as a recommendation 😁

E.g.

$null = Get-PSDrive $AccessPathDisk -ErrorAction Stop

Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1, line 541 at r1 (raw file):

         $TestDrive = Get-PSDrive $AccessPathDisk -ErrorAction Stop
    }
    Catch

Please use lower case C in catch.


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1, line 550 at r1 (raw file):

   
        Get-PSDrive | out-null

Assigning to $null is faster in older versions of PS (5.1 and below) rather than piping, so can you change to:

$null = Get-PSDrive

Also, how come this second Get-PSDrive is needed? The one above should be hit everytime.


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/en-us/MSFT_xDiskAccessPath.strings.psd1, line 1 at r1 (raw file):

Can you remove this extra blank line at the top here?


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/en-us/MSFT_xDiskAccessPath.strings.psd1, line 37 at r1 (raw file):

    TestingPSDriveMessage = Testing for availability of PSDrive {0} for AccessPath {1}
    UnavailablePSDriveMessage = PSDrive {0} is unavailable for AccessPath {1}, refreshing PSDrives.
  

Can you remove this extra blank line here?


Comments from Reviewable

@positivism1
Copy link
Author

Thank you! this is great, I will get to it as soon as I can. From what I remember from my testing, I put the change into Test-TargetResource because that is where the whole thing falls in a heap, when the test-path runs, it can't find the folder because psdrive need refreshing.

@PlagueHO PlagueHO changed the title xAccessPath: Fix issue 121 - Access Path not found xAccessPath: Access Path not found - Fixes #121 Dec 10, 2017
@positivism1
Copy link
Author

Getting back into this now. Apologies, have been away.

@positivism1
Copy link
Author

The psdrive refresh is in the Test-TargetResource because this is where the error occurs.

This code:
Get-PSDrive | out-null

Is the thing that does the work, only if this line errors..
$TestDrive = Get-PSDrive $AccessPathDisk -ErrorAction Stop

Without get-psdrive in catch block (error):
PowerShell DSC resource MSFT_xDiskAccessPath failed to execute Test-TargetResource functionality with error message: Access Path 'E:\DATA' is not found.
Parameter name: AccessPath
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure

With get-psdrive catch block (successful):
VERBOSE: [GDVRATST054]: [[xDiskAccessPath]dataAccessPath] Test-TargetResource: Testing disk with Number '2' status for access path 'E:\DATA'.
VERBOSE: [GDVRATST054]: [[xDiskAccessPath]dataAccessPath] Test-TargetResource: Testing for availability of PSDrive E for AccessPath E:\DATA
VERBOSE: [GDVRATST054]: [[xDiskAccessPath]dataAccessPath] Test-TargetResource: PSDrive E is unavailable for AccessPath E:\DATA, refreshing PSDrives.

Thanks, I will review the code, make changes and set it to Reviewable.

@PlagueHO
Copy link
Member

Hi @positivism1 - it looks like you've got some merge conflicts that need to be fixed. These will have been caused when another PR got merged before yours. If you can go into Reviewable and click Done on any changes you've completed and the click Publish that will allow me to acknowledge any required changes. Thanks again for your hard word!

@positivism1
Copy link
Author

ahh yep ok thanks :-) I will try get this Publish button to work.


Reviewed 1 of 3 files at r1, 1 of 1 files at r2, 2 of 2 files at r3.
Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed.


CHANGELOG.md, line 11 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Please remove extra space between existance and to.

Also existance should be spelled existence. 😁

Done.


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1, line 532 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

I think this code actually needs to be moved into the Set-TargetResource rather than in Test-TargetResource. You'd want to add it just after the volume has been formatted. The reason is that the first time Test-TargetResource is hit and the disk isn't already assigned then Get-PSDrive will fire twice and then Set-TargetResource will create the new drive. But Get-PSDrive needs to fire after the drive has been created but before you try and use it in one of your following steps.

So, I reckon this code needs to go in somewhere around here:
https://github.com/PowerShell/xStorage/blob/dev/Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1#L466

Convert to lower case T in Try.

Also, the alignment seems a bit off on this code block and there are a few extra spaces at the end of these lines.

The easiest way to fix it is to use Visual Studio Code format document feature. I wrote a quick blog post showing how to use it:
https://dscottraynsford.wordpress.com/2017/11/18/auto-formatting-powershell-in-visual-studio-code/

Done.


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1, line 534 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Please use lower case for first letter of local variables. E.g.

$AccessPathDisk = $AccessPath.split(":")[0]

Done.


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1, line 539 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

You could assign this to $null because the result will never be used. Visual Studio Code will underline this as a recommendation 😁

E.g.

$null = Get-PSDrive $AccessPathDisk -ErrorAction Stop

Done.


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1, line 541 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Please use lower case C in catch.

Done.


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/MSFT_xDiskAccessPath.psm1, line 550 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Assigning to $null is faster in older versions of PS (5.1 and below) rather than piping, so can you change to:

$null = Get-PSDrive

Also, how come this second Get-PSDrive is needed? The one above should be hit everytime.

This is the one that refreshes the psdrives, the one above tests if the drives are updated or not.


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/en-us/MSFT_xDiskAccessPath.strings.psd1, line 1 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Can you remove this extra blank line at the top here?

Done.


Modules/xStorage/DSCResources/MSFT_xDiskAccessPath/en-us/MSFT_xDiskAccessPath.strings.psd1, line 37 at r1 (raw file):

Previously, PlagueHO (Daniel Scott-Raynsford) wrote…

Can you remove this extra blank line here?

Done.


Comments from Reviewable

@PlagueHO
Copy link
Member

Hi @positivism1 - are you able to resolve the merge conflicts on this one? I merged another PR in which caused the conflicts.

@positivism1
Copy link
Author

Yes, would love to, but not exactly sure how. do I need to start again and do a new pull request? or do I manually somehow merge the changes?

@PlagueHO
Copy link
Member

HI @positivism1 - merge conflicts are super common and easy to fix. What you need to do is rebase your branch with the upstream dev branch. Take a look at these instructions: https://github.com/PowerShell/DscResources/blob/master/GettingStartedWithGitHub.md#resolve-merge-conflicts

Basically you'll bring the changes I've made to the upstream Dev branch into your branch, correct any merge conflicts and then push the changes back in. No need to create a new PR or anything.

The challenge will be in your case I had made a non-trivial change to xDiskAccess path to fix a long standing bug so you'll need to figure out how to merge your changes into mine. This hopefully is very straight forward - but if not, tag me and I'll see if I can help point you in the right direction.

@johlju johlju added waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. and removed needs review The pull request needs a code review. labels May 23, 2018
@johlju
Copy link
Member

johlju commented May 23, 2018

Labeling this PR as abandoned since it has gone 14 days or more since the last update. An abandoned PR can be continued by another contributor. The abandoned label will be removed if work on the PR is taken up again.

@johlju johlju added abandoned The pull request has been abandoned. and removed waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. labels May 23, 2018
@PlagueHO
Copy link
Member

Superceded by #209

@PlagueHO PlagueHO closed this Jul 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abandoned The pull request has been abandoned.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xDiskAccessPath fails test for disk and accesspath after disk format and folder creation.
5 participants