puppetlabs / puppetlabs/ruby-pwsh
Array of Hashes comparison result in a change at each run
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 20
- Forks
- 27
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 4
Description
Describe the Bug
When setting a resource that have a parameter with an Array of Hash, it compares with every entry of the hash, even though they are optional. This results in a perma-change (each run sets the resource again and again)
Expected Behavior
The values in the Array of Hash should not be set at each run
Steps to Reproduce
Module : webadministration dsc
Resource : dsc_website (assuming you have already set a pool to host the website)
dsc_website { 'machin.fr':
dsc_ensure => 'Present',
dsc_name => 'machin.fr',
dsc_physicalpath => 'd:/www/sites/machin.fr',
dsc_applicationpool => 'machin.fr',
dsc_bindinginfo => [{
hostname => 'machin.fr',
protocol => 'http',
port => 80,
}],
}
The part that is interesting is dsc_bindinginfo
The run (each run in fact) results with this
Notice: /Stage[main]/Main/Node[default]/Dsc_website[machin.fr]/dsc_bindinginfo: dsc_bindinginfo changed [
{
'bindinginformation' => '*:80:machin.fr',
'certificatestorename' => undef,
'certificatesubject' => undef,
'certificatethumbprint' => undef,
'hostname' => 'machin.fr',
'ipaddress' => '*',
'port' => 80,
'protocol' => 'http',
'sslflags' => '0'
}] to [
{
'hostname' => 'machin.fr',
'protocol' => 'http',
'port' => 80
}] (corrective)
Notice: dsc_website[{:name=>"machin.fr", :dsc_name=>"machin.fr"}]: Updating: Finished in 1.32 seconds
Environment
- Version 7.23
- Platform Windows 2022
Additional Context
-
There is an easy fix, but I do not find it acceptable. (It is using validation_mode: resource). It does resolve the issue but the execution time skyrockets from 0.1 sec to 1.5 sec. per website. Moreover, I think it concerns each parameter in every resources that has
mof_is_embedded: trueSo having each resource taking a full second, you end up easily with 5 min runs when you handle many resources. So I hope there is an alternative -
So here is the type definition of dsc_bindinginfo
dsc_bindinginfo: {
type: "Optional[Array[Struct[{
sslflags => Optional[Enum['0', '1', '2', '3']],
certificatestorename => Optional[Enum['My', 'my', 'WebHosting', 'webhosting']],
certificatethumbprint => Optional[String],
hostname => Optional[String],
certificatesubject => Optional[String],
bindinginformation => Optional[String],
port => Optional[Integer[0, 65535]],
ipaddress => Optional[String],
protocol => Enum['http', 'https', 'msmq.formatname', 'net.msmq', 'net.pipe', 'net.tcp']
}]]]",
desc: "Website's binding information in the form of an array of embedded instances of the DSC_WebBindingInformation CIM class.",
mandatory_for_get: false,
mandatory_for_set: false,
mof_type: 'DSC_WebBindingInformation[]',
mof_is_embedded: true,
},
The sub parameters are almost all optional.
I did try to specifiy them all by the way, but I can't specify undef for certificatestorename :( (and this would be a poor workaround)
I this the handling of this type of resources is link to mof_is_embedded: true (with a dedicated handling for pscredential)
I tried to debug dsc_base_provider.rb to understand what is causing this issue, but could not figure it out yet. :/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in dsc_base_provider.rb and reproduce the issue with the dsc_website resource's dsc_bindinginfo Array[Struct] on Windows Server 2022. Compare the normal run with validation_mode: resource and trace handling for mof_is_embedded fields. Done means optional hash values no longer cause a perma-change without the slower validation mode.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100