Skip to content

Deferred functions sometimes resolve too late with preprocess_deferred=false #9423

@bastelfreak

Description

@bastelfreak

Describe the Bug

After upgrading to Puppet 8 I noticed a problem with my elasticsearch_license type https://github.com/voxpupuli/puppet-elasticsearch/blob/master/lib/puppet/type/elasticsearch_license.rb -> https://github.com/voxpupuli/puppet-elasticsearch/blob/master/lib/puppet_x/elastic/elasticsearch_rest_resource.rb#L25-L27)

Roughly used like this:

class foo (
  $param, # set via Hiera
) {
  elasticsearch_license { 'xpack':
    password => $param.node_encrypt::secret,
    # and some more parameters
  }
}

This works fine with Puppet 7 or with Puppet 8 + preprocess_deferred=true. In with preprocess_deferred=false, the API authentication to elasticsearch fails. In the provider I added a Puppet.debug(password) and I get:

#<Puppet::Pops::Evaluator::DeferredValue:0x00007feadcbc5858>

It feels like the resolution or executed of the deferred function happens too late? But not all resources are broken. A simple file resource works:

class foo (
  $param, # set via Hiera
) {
  file { 'xpack':
    content => $param.node_encrypt::secret,
  }
}

This works, no matter if preprocess_deferred is true or false.

Expected Behavior

Deferred function should be evaluated before the type that uses the return value from the deferred function.

Steps to Reproduce

I don't have an easy to reproduce example at the moment. The Elasticsearch_license type requires a license and a working elasticsearch cluster.

Environment

  • PE 2021.7.8 / PE 2023.7.0

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions