PowerShell / PowerShell/DSC

Feature: Enable use of semantic exit codes for adapted PSDSC resources

Open
#1,380 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Enhancement
Dominant language
Rust
Stars
523
Forks
75
Avg merge
3d 16h
Merged PRs (30d)
24

Description

Summary of the new feature / enhancement

As a resource author implementing DSC resources as PowerShell classes,
I want to be able to provide semantic exit codes for my users,
so that my resources can fit into the semantics of DSC more correctly.

Currently, adapted PSDSC resources always return an exit code of 1 for an operational failure. There is no way for a resource implemented as a PowerShell class to:

  1. Indicate a set of exit codes and their meaning for DSC from the class implementation.
  2. Indicate a set of exit codes and their meaning for DSC from the adapted resource manifest.
  3. Surface that the operation is a failure and should exit with a specific code from any given resource operation.

[!NOTE]
This problem affects other adapters as well, but we only have the PowerShell adapters published.

Proposed technical implementation details (optional)

We should add an exitCodes field to the adapted resource manifest to ensure that adapted resources can propagate semantically defined exit codes to DSC and higher order tools.

I can address the specifics of how to retrieve the exit codes from a class definition in RFC0001, but I think we need a way to properly indicate a semantic exit code from within a class method. I can't see an immediately obvious way to do this without either providing a [DscOperationException] class or requiring the resource author to implement a custom exception that includes both an exit code and message that their resource class throws.

When an adapted resource doesn't provide semantic exit codes, we should treat the exit codes the same way we do for other resources (0 for success, 1 for failure). This is an opt-in enhancement for all resources, but currently adapted resource authors can't participate in these semantics.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/dsc-lib/src/dscresources/adapted_resource_manifest.rs and RFC0001/PR #1319 to trace how adapted resources currently represent exit codes. Define the class and manifest contract for semantic codes, including the default 0/1 behavior, and verify that resource operations can surface a specific failure code.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, rust
Domain
devops, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.