voxpupuli / puppet-corosync

Sets up and manages Corosync.
https://forge.puppet.com/puppet/corosync
Apache License 2.0
44 stars 159 forks source link

`cs_rsc_defaults` not committed from shadow cib to live cib #528

Open kossekm opened 1 year ago

kossekm commented 1 year ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

We have the following cs_rsc_defaults section in our Puppet hiera:

corosync_local::cs_rsc_defaults:
  record-pending: {name: 'record-pending', value: 'false'}
  failure-timeout: {name: 'failure-timeout', value: '2h'}
  timeout: {name: 'timeout', value: '120'}

What are you seeing

We added a cs_rsc_defaults section to our Pacemaker configuration. The section gets added to the shadow /var/cache/puppet/shadow.puppet file, but not to the live configuration.

What behaviour did you expect instead

We expect to see the following section in /var/lib/pacemaker/cib/cib.xml:

    <rsc_defaults>
      <meta_attributes id="rsc_defaults-meta_attributes">
        <nvpair id="rsc_defaults-meta_attributes-record-pending" name="record-pending" value="false"/>
        <nvpair id="rsc_defaults-meta_attributes-failure-timeout" name="failure-timeout" value="2h"/>
        <nvpair id="rsc_defaults-meta_attributes-timeout" name="timeout" value="120"/>
      </meta_attributes>
    </rsc_defaults>

Output log

Running the Puppet agent with debug mode enabled:

[root@host 08:08:04][host][~]# puppet agent -t --debug | grep cs_rsc_defaults -i
Debug: Puppet::Type::Cs_rsc_defaults::ProviderCrm: file crm does not exist
Debug: /Stage[main]/Corosync_local/Cs_rsc_defaults[record-pending]: Adding autorequire relationship with Service[corosync]
Debug: /Stage[main]/Corosync_local/Cs_rsc_defaults[record-pending]: Adding autorequire relationship with Service[pacemaker]
Debug: /Stage[main]/Corosync_local/Cs_rsc_defaults[failure-timeout]: Adding autorequire relationship with Service[corosync]
Debug: /Stage[main]/Corosync_local/Cs_rsc_defaults[failure-timeout]: Adding autorequire relationship with Service[pacemaker]
Debug: /Stage[main]/Corosync_local/Cs_rsc_defaults[timeout]: Adding autorequire relationship with Service[corosync]
Debug: /Stage[main]/Corosync_local/Cs_rsc_defaults[timeout]: Adding autorequire relationship with Service[pacemaker]
Debug: Prefetching pcs resources for cs_rsc_defaults
Debug: Puppet::Type::Cs_rsc_defaults::ProviderPcs: Executing ["/usr/sbin/pcs", "cluster", "cib"] in the CIB
Debug: Cs_rsc_defaults[record-pending](provider=pcs): {}
Notice: /Stage[main]/Corosync_local/Cs_rsc_defaults[record-pending]/ensure: created (corrective)
Debug: Puppet::Type::Cs_rsc_defaults::ProviderPcs: Executing ["/usr/sbin/pcs", "resource", "defaults", "record-pending=false", "-f", "/var/cache/puppet/shadow.puppet"] in the shadow CIB "puppet"
Debug: /Stage[main]/Corosync_local/Cs_rsc_defaults[record-pending]: The container Class[Corosync_local] will propagate my refresh event
Debug: Cs_rsc_defaults[failure-timeout](provider=pcs): {}
Notice: /Stage[main]/Corosync_local/Cs_rsc_defaults[failure-timeout]/ensure: created (corrective)
Debug: Puppet::Type::Cs_rsc_defaults::ProviderPcs: Executing ["/usr/sbin/pcs", "resource", "defaults", "failure-timeout=2h", "-f", "/var/cache/puppet/shadow.puppet"] in the shadow CIB "puppet"
Debug: /Stage[main]/Corosync_local/Cs_rsc_defaults[failure-timeout]: The container Class[Corosync_local] will propagate my refresh event
Debug: Cs_rsc_defaults[timeout](provider=pcs): {}
Notice: /Stage[main]/Corosync_local/Cs_rsc_defaults[timeout]/ensure: created (corrective)
Debug: Puppet::Type::Cs_rsc_defaults::ProviderPcs: Executing ["/usr/sbin/pcs", "resource", "defaults", "timeout=120", "-f", "/var/cache/puppet/shadow.puppet"] in the shadow CIB "puppet"
Debug: /Stage[main]/Corosync_local/Cs_rsc_defaults[timeout]: The container Class[Corosync_local] will propagate my refresh event

Any additional information you'd like to impart

I tested changing the upstream module in a branch to see if I could get the change applied to the live cib. The following change seemed to work.

In upstream/corosync/lib/puppet/type/cs_commit.rb add the following two blocks:

    autorequire(:cs_rsc_defaults) do
      resources_with_cib :cs_rsc_defaults
    end

and

    autosubscribe(:cs_rsc_defaults) do
      resources_with_cib :cs_rsc_defaults
    end

In upstream/corosync/lib/puppet/type/cs_rsc_defaults.rb add the following block:

  autorequire(:cs_shadow) do
    autos = []
    autos << @parameters[:cib].value if @parameters[:cib]
    autos
  end