PowerShell / DSC

This repo is for the DSC v3 project
MIT License
219 stars 30 forks source link

DSC/PowerShellGroup incorrect group inDesiredState #284

Open msftrubengu opened 1 year ago

msftrubengu commented 1 year ago

Prerequisites

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

SteveL-MSFT commented 5 months ago

It might make sense for test to only look at inDesiredState to determine state