Skip to content

Dsc properties are not compared correctly  #308

Open
@nickgw

Description

@nickgw

Describe the Bug

Somewhere between ruby-pwsh and the resource api, properties are getting lost and compared incorrectly.

for a relatively simple manifest with one dsc resource:

  dsc_virtualmemory { "set_page_file_size_of_24576" :
    dsc_type        => 'customsize',
    dsc_drive       => 'c',
    dsc_initialsize => 24576,
    dsc_maximumsize => 24576,
  }

The following is the truncated output on a verbose run:

Notice: /Stage[main]/Main/Dsc_virtualmemory[set_page_file_size_of_24576]/dsc_initialsize: dsc_initialsize changed  to 24576
Notice: /Stage[main]/Main/Dsc_virtualmemory[set_page_file_size_of_24576]/dsc_maximumsize: dsc_maximumsize changed  to 24576
Notice: dsc_virtualmemory[{:name=>"set_page_file_size_of_24576", :dsc_drive=>"c", :dsc_type=>"customsize"}]: Updating: Finished in 0.933907 seconds

Note that the change lines have a blank where the current value is omitted: dsc_initialsize changed to 24576

I've attached debug runs with and without the powershell to the issue, but this is the relevant part imo:

#PowerShell GET runs
2023-01-05 14:43:22 -0500 Puppet (debug): dsc_virtualmemory: raw data received: {"ResourceId"=>nil, "PsDscRunAsCredential"=>nil, "Type"=>"CustomSize", "InitialSize"=>24576, "ModuleVersion"=>"8.5.0", "SourceInfo"=>nil, "ConfigurationName"=>nil, "Drive"=>"C:\\", "MaximumSize"=>24576, "ModuleName"=>"C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet_x/computermanagementdsc/dsc_resources/ComputerManagementDsc/ComputerManagementDsc.psd1", "DependsOn"=>nil}
2023-01-05 14:43:22 -0500 Puppet (debug): dsc_virtualmemory: Returned to Puppet as {:dsc_drive=>"C:\\", :dsc_initialsize=>24576, :dsc_maximumsize=>24576, :dsc_type=>"CustomSize", :name=>"set_page_file_size_of_24576"}
2023-01-05 14:43:22 -0500 Puppet (debug): Current State: {:name=>"set_page_file_size_of_24576", :dsc_drive=>"c", :dsc_type=>"customsize"}
2023-01-05 14:43:22 -0500 Puppet (debug): dsc_virtualmemory: Canonicalized Resources: [{:name=>"set_page_file_size_of_24576", :dsc_drive=>"c", :dsc_type=>"customsize", :dsc_initialsize=>24576, :dsc_maximumsize=>24576, :validation_mode=>"property"}]
2023-01-05 14:43:22 -0500 /Stage[main]/Main/Dsc_virtualmemory[set_page_file_size_of_24576]/dsc_initialsize (notice): dsc_initialsize changed  to 24576
2023-01-05 14:43:22 -0500 /Stage[main]/Main/Dsc_virtualmemory[set_page_file_size_of_24576]/dsc_maximumsize (notice): dsc_maximumsize changed  to 24576

You can see that the raw data received has the correct data, and that that data is canonicalized correctly:
2023-01-05 14:43:22 -0500 Puppet (debug): dsc_virtualmemory: Canonicalized Resources: [{:name=>"set_page_file_size_of_24576", :dsc_drive=>"c", :dsc_type=>"customsize", :dsc_initialsize=>24576, :dsc_maximumsize=>24576, :validation_mode=>"property"}]

however, the current state has an incomplete list of properties:
2023-01-05 14:43:22 -0500 Puppet (debug): Current State: {:name=>"set_page_file_size_of_24576", :dsc_drive=>"c", :dsc_type=>"customsize"}

causing the resource's set function to run and printing this info:
2023-01-05 14:43:22 -0500 /Stage[main]/Main/Dsc_virtualmemory[set_page_file_size_of_24576]/dsc_initialsize (notice): dsc_initialsize changed to 24576

dsc_initialsize is changed from null to the correct value because the current state is incomplete.

Expected Behavior

I expect the current state to be the complete current state, and in this instance where the resource is in sync, nothing to happen.

Steps to Reproduce

Steps to reproduce the behavior:
On a system where ComputerManagementDsc is available, puppet apply a manifest with the resource at the beginning of the issue.

Environment

  • Version 7.19.0
  • Platform Windows 2019

Additional Context

This applies to a large portion of Dsc resources in Puppet. Flipping validation mode to resource "resolves" the problem, but negates much of the benefit of moving from the old dsc module to the newly released puppet dsc modules.
virtualmemory_debug_nopowershell.log
virtualmemory_debug_powershell.log

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