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

SqlSetup: Unable to enable debug mode #448

Closed
louis-li opened this issue Mar 19, 2017 · 10 comments · Fixed by #1301
Closed

SqlSetup: Unable to enable debug mode #448

louis-li opened this issue Mar 19, 2017 · 10 comments · Fixed by #1301
Labels
bug The issue is a bug.

Comments

@louis-li
Copy link

When I tried to enable debug mode for DSC by using:
Enable-DscDebug -BreakAll

Then when I run

Start-DscConfiguration -Path .\SQLServerSetup -Wait -Verbose -Force

Instead of entering breaking mode, it returns error:

Start-DscConfiguration -Path .\SQLServerSetup -Wait -Verbose -Force
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' =
MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer SQL2016 with user sid S-1-5-21-2704606996-4249334842-1457779825-500.
VERBOSE: [SQL2016]: LCM: [ Start Set ]
WARNING: [SQL2016]: [DSCEngine] Warning LCM is in Debug 'ResourceScriptBreakAll' mode. Resource s
cript processing will be stopped to wait for PowerShell script debugger to attach.
VERBOSE: [SQL2016]: [DSCEngine] Importing the module C:\Windows\system32\WindowsPowerShell\v1.0\Mo
dules\xSqlServer\5.0.0.0\DscResources\MSFT_xSQLServerSetup\MSFT_xSQLServerSetup.psm1 in force mode.
VERBOSE: [SQL2016]: [DSCEngine] Importing the module C:\Windows\system32\WindowsPowerShell\v1.0\Mo
dules\xSqlServer\5.0.0.0\DscResources\MSFT_xSQLServerFirewall\MSFT_xSQLServerFirewall.psm1 in force mode.
VERBOSE: [SQL2016]: [DSCEngine] Importing the module C:\Windows\system32\WindowsPowerShell\v1.0\Mo
dules\xSqlServer\5.0.0.0\DscResources\MSFT_xSQLServerMemory\MSFT_xSQLServerMemory.psm1 in force mode.
VERBOSE: [SQL2016]: [DSCEngine] Importing the module C:\Windows\system32\WindowsPowerShell\v1.0\Mo
dules\xSqlServer\5.0.0.0\DscResources\MSFT_xSQLServerConfiguration\MSFT_xSQLServerConfiguration.psm1 in force mode.
VERBOSE: [SQL2016]: [DSCEngine] Importing the module C:\Windows\system32\WindowsPowerShell\v1.0\Mo
dules\xSqlServer\5.0.0.0\DscResources\MSFT_xSQLServerMaxDop\MSFT_xSQLServerMaxDop.psm1 in force mode.
VERBOSE: [SQL2016]: LCM: [ Start Resource ] [[xSQLServerSetup]localhost]
VERBOSE: [SQL2016]: LCM: [ Start Test ] [[xSQLServerSetup]localhost]
VERBOSE: [SQL2016]: [[xSQLServerSetup]localhost] Importing the module MSFT_xSQLServerSetup in forc
e mode.
WARNING: [SQL2016]: [[xSQLServerSetup]localhost] Resource is waiting for PowerShell script debugge
r to attach. Use the following commands to begin debugging this resource script:
Enter-PSSession -ComputerName SQL2016 -Credential
Enter-PSHostProcess -Id 4308 -AppDomainName DscPsPluginWkr_AppDomain
Debug-Runspace -Id 22
VERBOSE: [SQL2016]: LCM: [ End Test ] [[xSQLServerSetup]localhost] in 0.1410 seconds.
PowerShell DSC resource MSFT_xSQLServerSetup failed to execute Test-TargetResource functionality with error message:
Object reference not set to an instance of an object.
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : localhost

VERBOSE: [SQL2016]: LCM: [ End Set ]
The SendConfigurationApply function did not succeed.
+ CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 1
+ PSComputerName : localhost

VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 0.887 seconds

I have tried to setup default values for the parameters and remove ALL logics in Test-TargetResource, it still returns same error.

@johlju
Copy link
Member

johlju commented Mar 19, 2017

Oh, it was such a long time since I debugged that way. So it can surely be a bug somewhere making this error.

Regarding that you get the same error when removing code in the resource. Did you set the DebugMode in the LCM so it does not cache the resource?
https://msdn.microsoft.com/en-us/powershell/dsc/metaconfig

What Windows Server and PowerShell version are you running on?

Labeling this as a question until we narrow it down to a bug in the resource.

@johlju johlju added the question The issue is a question. label Mar 19, 2017
@louis-li
Copy link
Author

Yes, the cached setting is set to ForceImportModule and all.

We tested on both SQL Server 2016 on Windows Server 2016 and SQL Server 2014 on Windows Server 2012R2 with WMF 5.1. Both failed with same error message.

@johlju
Copy link
Member

johlju commented Mar 20, 2017

I can reproduce this also.

VERBOSE: [SQLTEST]:                            [[xSQLServerSetup]InstallSQL2012Instance] Importing the module MSFT_xSQLServerSetup in force mode.
WARNING: [SQLTEST]:                            [[xSQLServerSetup]InstallSQL2012Instance] Resource is waiting for PowerShell script debugger to attach.  Use the following commands to begin debugging this resource script:
Enter-PSSession -ComputerName SQLTEST -Credential <credentials>
Enter-PSHostProcess -Id 3832 -AppDomainName DscPsPluginWkr_AppDomain
Debug-Runspace -Id 11
VERBOSE: [SQLTEST]: LCM:  [ End    Test     ]  [[xSQLServerSetup]InstallSQL2012Instance]  in 1.0670 seconds.
PowerShell DSC resource MSFT_xSQLServerSetup  failed to execute Test-TargetResource functionality with error message: Object reference not set to an instance of an object. 
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure

@gelarkin
Copy link

Hello has this issue been determined to be a bug in the resource?

@brwilkinson
Copy link

I would recommend to unblock your installation media.

Get-Childitem -Path f:\installsource -recurse | unblock-File

@johlju johlju changed the title 'xSQLServerSetup: Unable to enable debug mode SqlSetup: Unable to enable debug mode Dec 22, 2017
@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. and removed question The issue is a question. labels Jan 5, 2018
@johlju
Copy link
Member

johlju commented Jan 5, 2018

It is possible to debug SqlServerRole, but not SqlSetup. SqlSetup still today throws with the same error as in my last comment.
If it works, the debugger should stop at the top of the Test-TargetResource function, but for SqlSetup it just throws the error above.
My conclusion is that it can't be the code inside the Test-TargetResource but more likely that it does not like one or more of the parameters (or something else that happens before the debugger stops).

@mgreenegit can you provide any tips on what can cause this?

@nesith
Copy link
Contributor

nesith commented Mar 3, 2019

@johlju I'm working on this at the moment, so far I worked it to be an issue with either the mof class definition or with parameter definition.

Debugging steps

completely remove mof class definition parameters, added just the InstanceName and SourcePath to
mof class definition and then add same parametes to parameter definition of the test-tagertresource complied and run, and in debug mode it stopped as expected at the start of the test-target resource,
I am going to add parameter by parameter until either it stops working or it works :)

@johlju
Copy link
Member

johlju commented Mar 3, 2019

@nesith Awesome! I wonder what causes this in the schema - wrong type or a read only parameter, or something else... 🤔
Sounds your are close to figuring out what is causing this. 😃

@nesith
Copy link
Contributor

nesith commented Mar 4, 2019

@johlju I worked out that the issue is with

[Parameter(ParameterSetName = 'ClusterInstall')]
        [System.String]
        $FailoverClusterGroupName = "SQL Server ($InstanceName)"

specifically $InstanceName is not evaluated as expected.

I will let you know when I work out the solution.

This issue impacts the SET function as well

@johlju
Copy link
Member

johlju commented Mar 4, 2019

Aha! A solution might be a dynamic parameter, or easier, just assign the value in the code if the parameter is not assigned -not $PSBoundParameters.ContainsKey(‘FailoverClusterGroupName’).

Looking forward to a PR with the best solution you can find 😄

@nesith nesith mentioned this issue Mar 6, 2019
9 tasks
johlju pushed a commit that referenced this issue Jun 18, 2019
- Changes to SqlSetup
  - Changed the logic of how default value of FailoverClusterGroupName is
    set since that was preventing the resource to be able to be debugged
    (issue #448).
@johlju johlju removed the help wanted The issue is up for grabs for anyone in the community. label Apr 25, 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants