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

Puppet::Resources.search fails if conditions provided

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • PUP 5.0.1
    • PUP 6.24.0, PUP 7.9.0
    • None
    • Coremunity
    • Platform Core KANBAN
    • Needs Assessment
    • Bug Fix
    • Fixed bug that prevented the "Puppet::Resource.indirection.search" method from accepting conditions to filter results.
    • Needs Assessment

    Description

      The Puppet::Resource::Ral indirection appears to attempt to convert ral to_resource() twice when you provide search criteria (shown here with package). I'm guessing the specs are mocked such as to be validating the broken behavior.

      require 'puppet'
      require 'pp'
       
      packages = Puppet::Resource.indirection.search("package")
      pp packages.find { |r| r.name == 'Package/bash' }
       
      begin
        Puppet::Resource.indirection.search("package/bash")
      rescue Exception => e
        pp e.backtrace
        puts e
      end
       
      begin
        Puppet::Resource.indirection.search("package", {:ensure => "installed"})
      rescue Exception => e
        pp e.backtrace
        puts e
      end
      

      jpartlow@percival:~/work/src/pl/puppet$ be ruby test.rb 
      Package[bash]{:name=>"bash", :ensure=>"4.3-7ubuntu1.7", :provider=>:apt, :configfiles=>:keep, :reinstall_on_refresh=>:false, :loglevel=>:notice}
      ["/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:27:in `block (2 levels) in search'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:27:in `each'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:27:in `all?'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:27:in `block in search'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:26:in `each'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:26:in `find_all'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:26:in `search'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/indirection.rb:270:in `search'",
       "test.rb:8:in `<main>'"]
      undefined method `to_resource' for #<Puppet::Resource:0x007f1c8e0d57f8>
      ["/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:27:in `block (2 levels) in search'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:27:in `each'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:27:in `all?'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:27:in `block in search'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:26:in `each'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:26:in `find_all'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/resource/ral.rb:26:in `search'",
       "/home/jpartlow/work/src/pl/puppet/lib/puppet/indirector/indirection.rb:270:in `search'",
       "test.rb:15:in `<main>'"]
      undefined method `to_resource' for #<Puppet::Resource:0x007f1c8dacac00>
      

      Attachments

        Activity

          People

            josh Josh Cooper
            joshua.partlow Joshua Partlow
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support