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

xRegistry cannot change value type #436

Closed
SylvainMartel opened this issue Aug 2, 2018 · 7 comments
Closed

xRegistry cannot change value type #436

SylvainMartel opened this issue Aug 2, 2018 · 7 comments
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub

Comments

@SylvainMartel
Copy link

In our environment, a registry key was wrongly created as a QWord instead of a DWord. DSC caught this, but it fails to fix it as the Set part does not seem to take this into account?

Here is the part where it detect the wrong value:

VERBOSE: [POC02]: [[Registry]TCPKeepAlive::[DSQ_ConfigNoyau]Noyau] The type of the value KeepAliveTime under the registry key at path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters does not match the expected type.
Expected DWord but was QWord.

and here is the set part

VERBOSE: [POC02]: [[Registry]TCPKeepAlive::[DSQ_ConfigNoyau]Noyau] Set-TargetResource is starting for Registry resource with Key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters
VERBOSE: [POC02]: [[Registry]TCPKeepAlive::[DSQ_ConfigNoyau]Noyau] The registry key at path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters exists.
VERBOSE: [POC02]: [[Registry]TCPKeepAlive::[DSQ_ConfigNoyau]Noyau] The value KeepAliveTime under the registry key at path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters has already been set to the specified value.
VERBOSE: [POC02]: [[Registry]TCPKeepAlive::[DSQ_ConfigNoyau]Noyau] Set-TargetResource has finished for Registry resource with Key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters

As you can see, it says that the value has "already been set to the specified value", so the set part does not seem to verify the Type.

As such, the node is always reported as not in the desired state.

@johlju
Copy link
Member

johlju commented Aug 3, 2018

Thanks for reporting this!

It seems this is tested here in the Test-TargetResource function, but it is not tested in the Set-TargetResource.

https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/1063b2ffc7c3f95a1a3464568e180461cf899217/DSCResources/MSFT_xRegistryResource/MSFT_xRegistryResource.psm1#L457-L462

The check above seems it could be moved into this helper function that is called by both Test-TargetResource and Set-TargetResource.

https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/1063b2ffc7c3f95a1a3464568e180461cf899217/DSCResources/MSFT_xRegistryResource/MSFT_xRegistryResource.psm1#L1354

With this change, and using the -Force parameter, then the helper function Set-RegistryKeyValue is called (which looks like it will overwrite the value with the new type).

https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/1063b2ffc7c3f95a1a3464568e180461cf899217/DSCResources/MSFT_xRegistryResource/MSFT_xRegistryResource.psm1#L272-L291

@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub labels Aug 3, 2018
@johlju
Copy link
Member

johlju commented Aug 3, 2018

Labeled this help wanted so that anyone in the community can run with this. This looks like a good issue for someone who wants to learn how to write a (regression) tests for test driven development.

@albvar
Copy link

albvar commented May 31, 2019

I was just about to report this exact issue. Noticed issue reported on 8/2018, there must be a huge backlog? Anyhow up-voting this, noticed it with version 8.6.0.0.

@mhendric
Copy link
Contributor

mhendric commented Jun 3, 2019

@albvar , there has indeed been a huge backlog, as well as a lack of volunteers. I don't suppose you want to volunteer to help with this one? :)

@mkht
Copy link
Contributor

mkht commented Dec 25, 2019

It is a disappointment that those who tackle this issue do not appear for a long time.
Now I am working on this and will create a PR soon.

@mkht
Copy link
Contributor

mkht commented Jan 11, 2020

This bug has been fixed in PR #658 . Please close this issue.
@johlju @PlagueHO

@gaelcolas
Copy link
Member

Glad it's finally fixed. Thanks for your contribution @mkht !

@johlju johlju removed the help wanted The issue is up for grabs for anyone in the community. label Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub
Projects
None yet
Development

No branches or pull requests

6 participants