Class based DSC resource intermittently fails

Welcome Forums DSC (Desired State Configuration) Class based DSC resource intermittently fails

This topic contains 4 replies, has 2 voices, and was last updated by

2 years, 6 months ago.

  • Author
  • #47345

    Points: 94
    Rank: Member
    OS         : Windows 2012 R2
    OS Version : 6.3.9600
    PSVersion  : 5.0.10586.117

    While working on Class based DSC resource I encountered some issues and inconsistencies I can't explain.
    I've created a small 'project' help to troubleshooting:

    The issue is, if I run the configuration in the example/ folder:

    It fails the first time, works the second, and then it's like 'works','fails' | Get-Random for subsequent attempts.

    The class is meant to be very simple:

    So is the configuration:

    I'll add a gif of the output I get when I run it in the git repo's readme.

    It's worth noting that on my laptop (Win 10 TP Fast ring), it works every time:

    OS         : Windows 10
    OS Version : 10.0.14390
    PSVersion  : 5.1.14390.0

    Any idea of what I might be doing wrong? Or does it sound like an issue with the WMF5 on Win2012r2?

  • #47355

    Points: 0
    Rank: Member

    There were definitely some pain points with class-based resources at first, and so far, I still haven't used them in production. What do you mean by "fails", though? What error message are you seeing?

  • #47370

    Points: 94
    Rank: Member

    Thanks Dave.
    Here's what I get:

    VERBOSE: [WIN-8SU88BLP5RK]: LCM:  [ Start  Resource ]  [[Env_Refresh]TESTVAR]
    VERBOSE: [WIN-8SU88BLP5RK]: LCM:  [ Start  Test     ]  [[Env_Refresh]TESTVAR]
    VERBOSE: [WIN-8SU88BLP5RK]:                            [[Env_Refresh]TESTVAR] Importing the module
    Env_Refresh in force mode.
    Object reference not set to an instance of an object.
        + CategoryInfo          : OperationStopped: (:) [], CimException
        + FullyQualifiedErrorId : System.NullReferenceException
        + PSComputerName        : localhost
    VERBOSE: [WIN-8SU88BLP5RK]: LCM:  [ End    Test     ]  [[Env_Refresh]TESTVAR]  in 0.0780 seconds.
    The PowerShell DSC resource '[Env_Refresh]TESTVAR' with SourceInfo 'C:\Users\Administrator\AppData\Local\Temp
    \kitchen\modules\Env_Refresh\examples\dsc_configuration.ps1::5::9::Env_Refresh' threw one or more
    non-terminating errors while running the Test functionality. These errors are logged to the ETW channel
    called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
        + CategoryInfo          : InvalidOperation: (:) [], CimException
        + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
        + PSComputerName        : localhost
    VERBOSE: [WIN-8SU88BLP5RK]: 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.176 seconds
    []: PS C:\Users\Administrator\AppData\Local\Temp\kitchen\modules\Env_Refresh>

    It errors less often when I don't have another configuration entry AFTER my Env_Refresh TESTVAR {...}.

    Also added a gif on my repo's readme:

    It took 4 tries before actually raising the error.

  • #47373

    Points: 0
    Rank: Member

    I've seen some people report that same error on the MVP mailing list as well. If Microsoft has fixed it in the latest Fast Ring builds, great (once that version of PowerShell hits general release on the downlevel operating systems.)

    I don't know if this will help, but in the email thread I'm looking at, they mention that the error was only happening if they had the LCM's DebugMode set to something other than 'None'. (ForceModuleImport, etc).

  • #47427

    Points: 94
    Rank: Member

    This was spot on, the problem exist only when the Debug mode is set to something else than NONE.
    On my Test-Kitchen configuration file .kitchen.yml I had

        name: dsc
        dsc_local_configuration_manager_version: wmf5
          reboot_if_needed: true
          configuration_mode_frequency_mins: 15
          debug_mode: All

    Changing with debug_mode: None fixed my issue. (or amending the LCM via Set-DscLocalConfigurationManager)

    After that I tested on my laptop with the debug_mode: All, and it still worked.
    I suspect that bug has been fixed in WMF 5.1 (PSVersion 5.1.14390.0), but confirmation would be great (we may have to wait for WMF5.1 release and its release notes).

    I have opened a UserVoice for this as I could not find any:

The topic ‘Class based DSC resource intermittently fails’ is closed to new replies.