PowerShell / PowerShell/DSC

DSC/PowerShellGroup incorrect group inDesiredState

Open
#284 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

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

When all the resources in a PowerShellGroup are in the desired state, the group's inDesired state property is false. Looking at the code, I think it is because dsc compares the desiredState with actualState, but in the case of a PowerShellGroup the results are always going to be a single element with InDesiredState or an array of with the resources InDesiredState. Maybe dsc has to special case this group's result.

Expected behavior
Group's inDesiredState should be true if all its resource are in the desired state.
Actual behavior
PS D:\Dev\DSC> dsc resource test -r DSC/PowerShellGroup -i '{ "resources": [ { "name": "test", "type": "xE2ETestResource/E2EFileResource", "properties": { "path": "D:\\Dev\\DscV3\\testv3.txt", "content": "test" } } ] }'
  2023-11-21T21:59:55.212660Z  INFO dsc_lib::dscresources::command_resource: Invoking test DSC/PowerShellGroup using pwsh
    at D:\Dev\DSC\dsc_lib\src\dscresources\command_resource.rs:232

desiredState:
  resources:
  - name: test
    type: xE2ETestResource/E2EFileResource
    properties:
      path: D:\Dev\DscV3\testv3.txt
      content: test
actualState:
  InDesiredState: false
inDesiredState: false
differingProperties:
- resources
PS D:\Dev\DSC> dsc resource set -r DSC/PowerShellGroup -i '{ "resources": [ { "name": "test", "type": "xE2ETestResource/E2EFileResource", "properties": { "path": "D:\\Dev\\DscV3\\testv3.txt", "content": "test" } } ] }'
  2023-11-21T22:00:40.620243Z  INFO dsc_lib::dscresources::command_resource: Getting current state for set by invoking get DSC/PowerShellGroup using pwsh
    at D:\Dev\DSC\dsc_lib\src\dscresources\command_resource.rs:132

  2023-11-21T22:00:49.253187Z  INFO dsc_lib::dscresources::command_resource: Invoking set DSC/PowerShellGroup using pwsh
    at D:\Dev\DSC\dsc_lib\src\dscresources\command_resource.rs:145

beforeState:
  Path: D:\Dev\DscV3\testv3.txt
  Ensure: Present
  Content: ''
afterState:
  RebootRequired: false
changedProperties:
- RebootRequired
PS D:\Dev\DSC> dsc resource test -r DSC/PowerShellGroup -i '{ "resources": [ { "name": "test", "type": "xE2ETestResource/E2EFileResource", "properties": { "path": "D:\\Dev\\DscV3\\testv3.txt", "content": "test" } } ] }'
  2023-11-21T22:01:11.628882Z  INFO dsc_lib::dscresources::command_resource: Invoking test DSC/PowerShellGroup using pwsh
    at D:\Dev\DSC\dsc_lib\src\dscresources\command_resource.rs:232

desiredState:
  resources:
  - name: test
    type: xE2ETestResource/E2EFileResource
    properties:
      path: D:\Dev\DscV3\testv3.txt
      content: test
actualState:
  InDesiredState: true
inDesiredState: false
differingProperties:
- resources
Error details

No response

Environment data
PS D:\Dev\DSC> $PSVersionTable

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

v3.0.0-alpha.4

Visuals

No response

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 the DSC/PowerShellGroup path exercised by dsc resource test, then inspect dsc_lib/src/dscresources/command_resource.rs around the logged line 232 and the desired/actual state comparison. Reproduce the two test commands from the issue and verify that a group reports inDesiredState true when its resource result is true and all resources are compliant.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, rust
Domain
devops, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.