Skip to content

DSC doesnt propagate exit code correctly #817

Open
@Gijsreyn

Description

@Gijsreyn

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Summary

I am experiencing an issue when creating a custom DSC v3 resource. This was discovered while developing the win32service using Python. The resource needs to be elevated to get data from the SCM. If it is not elevated, it will throw an access denied error.

I'm capturing this error to later propagate it to DSC's engine in the resource manifest as such:

"exitCodes": {
        "0": "Success",
        "1": "Invalid parameter",
        "2": "Invalid input",
        "3": "Service error",
        "4": "JSON serialization failed"
    },

When looking at both, I can see the following:

Image

Doing the same in the engine results in an exit code 2, even though it tells me 3:

Image

Steps to reproduce

  1. Create the following configuration document
$config = @{
            '$schema' = 'https://aka.ms/dsc/schemas/v3/bundled/config/document.json'
            resources = @(
                @{
                    name = 'service'
                    type = 'DSCResources.Windows/Win32Service'
                    properties = @{
                        name = 'NewService'
                        path       = (Get-Process -Id $PID).Path
                        _exist = $true
                    }
                }
            )
        }
  1. Run dsc config set --input ($config | ConvertTo-Json -Depth 10)

If you need access to the repository containing the resource, let me know

Expected behavior

The exit code should be 3

Actual behavior

The exit code is 2

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.7
PSEdition                      Core
GitCommitId                    7.4.7
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

dsc 3.1.0-preview.5

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions