Jira (PUP-7799) Puppet::Resources.search fails if conditions provided

1 view
Skip to first unread message

Joshua Partlow (JIRA)

unread,
Jul 21, 2017, 7:38:02 PM7/21/17
to puppe...@googlegroups.com
Joshua Partlow created an issue
 
Puppet / Bug PUP-7799
Puppet::Resources.search fails if conditions provided
Issue Type: Bug Bug
Affects Versions: PUP 5.0.1
Assignee: Unassigned
Created: 2017/07/21 4:37 PM
Priority: Normal Normal
Reporter: Joshua Partlow

The Puppet::Resource::Ral indirectory 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>

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Josh Cooper (JIRA)

unread,
Jul 31, 2017, 6:08:02 PM7/31/17
to puppe...@googlegroups.com

Joshua Partlow (JIRA)

unread,
Jul 31, 2017, 6:45:02 PM7/31/17
to puppe...@googlegroups.com
Joshua Partlow updated an issue
Change By: Joshua Partlow
The [Puppet::Resource::Ral  indirectory  indirection |https://github.com/puppetlabs/puppet/blob/5.0.1/lib/puppet/indirector/resource/ral.rb#L24-L27] 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.

{code}

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
{code}

{code}

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>
{code}

Josh Cooper (Jira)

unread,
Jun 11, 2021, 2:57:02 PM6/11/21
to puppe...@googlegroups.com
Josh Cooper assigned an issue to Josh Cooper
Change By: Josh Cooper
Assignee: Josh Cooper
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Jun 11, 2021, 3:21:03 PM6/11/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Platform Core KANBAN

Josh Cooper (Jira)

unread,
Jun 14, 2021, 2:17:02 PM6/14/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: PUP 7.9.0
Fix Version/s: PUP 6.24.0

Josh Cooper (Jira)

unread,
Jun 14, 2021, 2:18:01 PM6/14/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Release Notes: Bug Fix
Release Notes Summary: Fixed bug that prevented the "Puppet::Resource.indirection.search" method from accepting conditions to filter results.

Josh Cooper (Jira)

unread,
Jun 14, 2021, 2:22:02 PM6/14/21
to puppe...@googlegroups.com

Claire Cadman (Jira)

unread,
Jul 13, 2021, 6:44:02 AM7/13/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages