-
Notifications
You must be signed in to change notification settings - Fork 54
Improve speed of Test-IsNanoServer function #141
Conversation
Replace Get-ComputerInfo with Registry Value Test
Codecov Report
@@ Coverage Diff @@
## dev #141 +/- ##
===================================
- Coverage 83% 83% -1%
===================================
Files 19 19
Lines 2760 2760
Branches 4 4
===================================
- Hits 2305 2303 -2
- Misses 451 453 +2
Partials 4 4 |
Hey @X-Guardian , thanks for the contribution. I was looking through your build log, and it looks like you're failing in xMsiPackage. I've actually been troubleshooting the exact same issue over in xPSDesiredStateConfiguration. I have a fix almost ready to go and will try to submit it this week. I'll do the same in this repo. The problem seems to occur on machines that default to using only SSL3 and TLS 1.0 for .NET, and the fix is to set SchUseStrongCrypto to true on the test machine, which allows TLS 1.1 and TLS 1.2 to be used. https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls#schusestrongcrypto Probable fix:
|
Opened #142 to track the issue above |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @X-Guardian)
README.md, line 624 at r2 (raw file):
* Improved speed of Test-IsNanoServer function
This needs to be under the 'Unreleased' section, not underneath an existing version.
DscResources/CommonResourceHelper.psm1, line 11 at r2 (raw file):
Quoted 17 lines of code…
$ServerLevelsRegKey = 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Server\ServerLevels' If (Test-Path $ServerLevelsRegKey) { $ServerLevels = Get-ItemProperty -Path $ServerLevelsRegKey If ($ServerLevels.NanoServer -eq 1) { $isNanoServer = $true } Else { $isNanoServer = $false } } Else { $isNanoServer = $false
Can you make the If and Else all lowercase, and also start local variables with a lowercase letter (serverLevelsRegKey , serverLevels)
DscResources/CommonResourceHelper.psm1, line 12 at r2 (raw file):
Test-Path $ServerLevelsRegKey)
Need a named -Path parameter here
Tests/Unit/CommonResourceHelper.Tests.ps1, line 41 at r2 (raw file):
Mock -CommandName 'Get-ItemProperty' -MockWith { return $testComputerInfoServerNotNano }
Can you remove the whitespace on the end of this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 3 files reviewed, 4 unresolved discussions (waiting on @mhendric)
README.md, line 624 at r2 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
* Improved speed of Test-IsNanoServer function
This needs to be under the 'Unreleased' section, not underneath an existing version.
Done.
DscResources/CommonResourceHelper.psm1, line 11 at r2 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
$ServerLevelsRegKey = 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Server\ServerLevels' If (Test-Path $ServerLevelsRegKey) { $ServerLevels = Get-ItemProperty -Path $ServerLevelsRegKey If ($ServerLevels.NanoServer -eq 1) { $isNanoServer = $true } Else { $isNanoServer = $false } } Else { $isNanoServer = $false
Can you make the If and Else all lowercase, and also start local variables with a lowercase letter (serverLevelsRegKey , serverLevels)
Done.
DscResources/CommonResourceHelper.psm1, line 12 at r2 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
Test-Path $ServerLevelsRegKey)
Need a named -Path parameter here
Done.
Tests/Unit/CommonResourceHelper.Tests.ps1, line 41 at r2 (raw file):
Previously, mhendric (Mike Hendrickson) wrote…
Mock -CommandName 'Get-ItemProperty' -MockWith { return $testComputerInfoServerNotNano }
Can you remove the whitespace on the end of this line?
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @mhendric)
Thanks for the updates @X-Guardian . This will need to be re-based, but I suggest waiting until #143 (pending review) is checked in. |
Hey @X-Guardian , #143 has now been checked in. Can you rebase and see if that resolves your issue? |
Hi @mhendric, my branch for this PR seems to have got lost. I've restored the branch on my forked Repo (https://github.com/X-Guardian/PSDscResources/tree/Test-IsNanoServer) but its now not linked to this PR. Anything you can do from your end, or shall I create a new PR? |
Hi @X-Guardian . I've never tried this myself, but I think these instructions are pretty close to what you need to do. But these rely on creating a new PR as well. I'm not aware of any way to continue a PR when the original branch is lost (although I'm by no means a Git expert). Creating a new PR is probably the easiest way to get out of this. |
Replaced by #154 |
Pull Request (PR) description
Currently, the
Test-IsNanoServer
function calls theGet-ComputerInfo
cmdlet to check with the computer is running Nano server or not.Get-ComputerInfo
can take 40+ seconds to run each time. This function is called for each user and group resource within a Dsc configuration and therefore can make the Dsc application very slow.This PR replaces
Get-ComputerInfo
with checking the registry value atHKLM:\Software\Microsoft\Windows NT\CurrentVersion\Server\ServerLevels\NanoServer
, as documented here: https://msdn.microsoft.com/en-us/library/windows/desktop/hh846315(v=vs.85).aspxThis Pull Request (PR) fixes the following issues
None
Task list
Entry should say what was changed, and how that affects users (if applicable).
and comment-based help.
This change is