voxpupuli/puppet-corosync

Provider pcs for cs_location type does not set resource_discovery when using rules

Opened this issue · 1 comments

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.5.2
  • Ruby: ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-linux]
  • Distribution: Ubuntu 18.04
  • Module version: 6.0.1

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

Create a cs_location which does not set node_name but does set rules.

cs_location { "location_${primitive_name}":
  primitive          => "${primitive_name}",
  resource_discovery => 'never',
  rules              => [
    # Avoid hosts which do not have the required attribute
    {
      "${primitive_name}_require-foo" => {
        'score'      => '-INFINITY',
        'boolean-op' => 'or',
        'expression' => [
          {
            'attribute' => 'foo',
            'operation' => 'not_defined',
          },
          {
            'attribute' => 'foo',
            'operation' => 'ne',
            'value'     => 'true', # lint:ignore:quoted_booleans
          },
        ],
      },
    },
  ],
  cib                => 'test',
}

What are you seeing

The constraint is created without the resource-discovery attribute being set.

What behaviour did you expect instead

The resource-discovery attribute to be set.

Any additional information you'd like to impart

Looking at the source, resource discovery is only set when a node is specified:

cmd << "resource-discovery=#{@property_hash[:resource_discovery]}" unless @property_hash[:resource_discovery].nil?

Adding params << "resource-discovery=#{@property_hash[:resource_discovery]}" if count.zero? unless @property_hash[:resource_discovery].nil? to the following block should fix the issue but I haven't tested this yet:

params << "id=#{name}"
params << "constraint-id=#{@resource[:name]}" if count.zero?
params << "role=#{rule['role']}" unless rule['role'].nil?
params << score
params += expression

Currently I am unable to use the crm provider because of #447 and the pcs provider because of this issue.

Hi @qcfabrizio - You are right. Can you submit a PR with your proposal?