-
Notifications
You must be signed in to change notification settings - Fork 83
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
ScheduledTask: Unable to enter Debug Mode #231
Comments
Thanks for raising this @ShawnHardwick. Are you able to share the DSC Config you're using (with specifics redacted)? @johlju - do you recall what the exact cause of this problem was over in SqlServerDsc? |
In the SqlServerDsc case it was a parameter that set a default value from another parameter param
(
[Parameter(Mandatory = $true)]
[System.String]
$InstanceName
[Parameter()]
[System.String]
$FailoverClusterGroupName = "SQL Server ($InstanceName)"
) It failed on |
Maybe it fails on this? The solution was to set the default value as the first thing in the code, instead of setting it in the param block. |
I actually use Puppet to call DSC so I'll provide what Puppet calls and what I call directly to debug the code.
|
@ShawnHardwick to just rule this out. In these locations can you remove the Than in the start of each function Get-TargetResource, Test-TargetResource and Set-TargetResource please add these rows. Alternative to adding the below rows, you could add the if (-not $PSBoundParameters.ContainsKey('StartTime'))
{
$StartTime = [System.DateTime]::Today
} This is the only thing I can see that is close to the problem in SqlServerDsc, it would be nice to rule it out. |
That appears to have fixed it. I can use It's interesting to know now that the DSC debug fails if the default value for a parameter needs to be derived from a function or another parameter. Just curious, if this has been broken for this resource, how do other people step through DSC code? |
Thanks @johlju - great info. I'll look at incorporating changes into the resource over the weekend. @ShawnHardwick , in answer to your question, I very rarely use DSC debugging, generally relying on unit tests/integration tests. I try to use a red-green refactor (TDD) approach when writing resources. This doesn't eliminate the need for debugging, but does make it a rare enough occurrence. I'm not completely sure why the conditions @johlju identified would have caused problems debugging DSC, but I'll look into it a bit more. Might also be something we can test for as well. |
Details of the scenario you tried and the problem that is occurring
Enabling DSC debug with
Enable-DSCDebug -BreakAll
and then running the ScheduledTask resource returns an error:Verbose logs showing the problem
Suggested solution to the issue
See the below issue for the same problem in a different DSC module:
dsccommunity/SqlServerDsc#448
The DSC configuration that is used to reproduce the issue (as detailed as possible)
No configuration to provide
The operating system the target node is running
Version and build of PowerShell the target node is running
Version of the DSC module that was used ('dev' if using current dev branch)
6.4.0.0
The text was updated successfully, but these errors were encountered: