Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-6321

undef in custom type autorequire value causes error in Puppet 4.5.0

    Details

    • Template:
    • Acceptance Criteria:
      Hide

      That the reproducer does not error:

      # sudo rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
      # yum install puppet-agent
      # /opt/puppetlabs/puppet/bin/puppet --version
      4.5.0
      # /opt/puppetlabs/puppet/bin/puppet module install puppet/archive --version 0.5.1
      # # cat > foo.pp <<EOF
      archive { 'git-client.hpi':
         source => 'https://updates.jenkins-ci.org/download/plugins/git-client/1.19.6/git-client.hpi',
         path => '/tmp/git-client.hpi',
         checksum_verify => false,
         checksum => undef,
         checksum_type => 'sha1',
         proxy_server => undef,
         cleanup => false,
         extract => false,
      }
      EOF
      # puppet apply ./foo.pp
      

      Show
      That the reproducer does not error: # sudo rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm # yum install puppet-agent # /opt/puppetlabs/puppet/bin/puppet --version 4.5.0 # /opt/puppetlabs/puppet/bin/puppet module install puppet/archive --version 0.5.1 # # cat > foo.pp <<EOF archive { 'git-client.hpi': source => 'https://updates.jenkins-ci.org/download/plugins/git-client/1.19.6/git-client.hpi', path => '/tmp/git-client.hpi', checksum_verify => false, checksum => undef, checksum_type => 'sha1', proxy_server => undef, cleanup => false, extract => false, } EOF # puppet apply ./foo.pp
    • Story Points:
      1
    • Sprint:
      Language 2016-06-01
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      A regression from Puppet 4.4 caused types that used autorequire to fail when the referenced set contained undef entries. This could also be the cause of other errors (although none have been reported at this time).

      Description

      The voxpupuli archive module contains a custom type that adds some file autorequires:

      https://github.com/voxpupuli/puppet-archive/blob/v0.5.1/lib/puppet/type/archive.rb#L162-L169

      autorequire(:file) do
          [
            Pathname.new(self[:path]).parent.to_s,
            self[:extract_path],
            '/root/.aws/config',
            '/root/.aws/credentials',
          ]
        end
      

      In this code, it is possible for self[:extract_path] to be undef if a user declares the resource without specifying it. In Puppet 4.4.1, this does not cause a problem. In Puppet 4.5.0, this results in the following error:

      Error: Failed to apply catalog: No title provided and :file is not a valid resource reference
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:544:in `extract_type_and_title'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource.rb:529:in `type_and_title'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:353:in `resource'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:2138:in `block (2 levels) in autorelation'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:2134:in `each'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:2134:in `block in autorelation'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:2069:in `block in eachautorequire'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:2068:in `each'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:2068:in `eachautorequire'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:2125:in `autorelation'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:2155:in `autorequire'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:169:in `block (2 levels) in build_autorelation_dependencies'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:168:in `each'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:168:in `block in build_autorelation_dependencies'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:167:in `each'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:167:in `build_autorelation_dependencies'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:25:in `populate_from'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:246:in `relationship_graph'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:175:in `relationship_graph'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:141:in `evaluate'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:222:in `block in apply'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/log.rb:155:in `with_destination'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/report.rb:118:in `as_logging_destination'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:221:in `apply'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:171:in `block in apply_catalog'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:223:in `block in benchmark'
      /opt/puppetlabs/puppet/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:222:in `benchmark'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:170:in `apply_catalog'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:315:in `run_internal'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:186:in `block in run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:65:in `override'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:240:in `override'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:185:in `run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:350:in `apply_catalog'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:274:in `block in main'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:65:in `override'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:240:in `override'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:225:in `main'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/apply.rb:170:in `run_command'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `block in run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:540:in `exit_on_fail'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:128:in `run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:72:in `execute'
      /opt/puppetlabs/puppet/bin/puppet:5:in `<main>'
      

      Here are steps that can be used to reproduce on a clean CentOS7 VM:

      # sudo rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
      # yum install puppet-agent
      # /opt/puppetlabs/puppet/bin/puppet --version
      4.5.0
      # /opt/puppetlabs/puppet/bin/puppet module install puppet/archive --version 0.5.1
      # # cat > foo.pp <<EOF
      archive { 'git-client.hpi':
         source => 'https://updates.jenkins-ci.org/download/plugins/git-client/1.19.6/git-client.hpi',
         path => '/tmp/git-client.hpi',
         checksum_verify => false,
         checksum => undef,
         checksum_type => 'sha1',
         proxy_server => undef,
         cleanup => false,
         extract => false,
      }
      EOF
      # puppet apply ./foo.pp
      Notice: Compiled catalog for blah.blah in environment production in 0.08 seconds
      Error: Failed to apply catalog: No title provided and :file is not a valid resource reference
      

      Downgrading to an older version of Puppet fixes the issue:

      # yum downgrade puppet-agent-1.4.1-1.el7
      # /opt/puppetlabs/puppet/bin/puppet --version
      4.4.1
      # /opt/puppetlabs/puppet/bin/puppet apply foo.pp
      Notice: Compiled catalog for blah.blah in environment production in 0.07 seconds
      Notice: /Stage[main]/Main/Archive[git-client.hpi]/ensure: replace archive: /tmp/git-client.hpi from (sha1)7ab5b9ec5635084ce192402e2d3203d2dfd66e65 to (sha1)
      Notice: Applied catalog in 1.64 seconds
      

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  chris Chris Price
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  11 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Zendesk Support