Jira (PUP-7497) puppet resource package command fails to list all packages

3 views
Skip to first unread message

Thomas Kishel (JIRA)

unread,
May 4, 2017, 3:05:03 PM5/4/17
to puppe...@googlegroups.com
Thomas Kishel created an issue
 
Puppet / Bug PUP-7497
puppet resource package command fails to list all packages
Issue Type: Bug Bug
Affects Versions: PUP 4.9.4
Assignee: Unassigned
Created: 2017/05/04 12:04 PM
Environment:

Linux and Windows

Priority: Normal Normal
Reporter: Thomas Kishel

Issue:

The puppet resource package command used to list packages discards identically named resources managed by multiple providers.

This results in an inaccurate list of packages.

Test:

# SYSTEM RUBY
 
[root@pe-20172nightly-master ~]# gem list
 
*** LOCAL GEMS ***
 
geocoder (1.4.3)
trollop (2.0)
 
# PUPPET RUBY
 
[root@pe-2017-master ~]# /opt/puppetlabs/puppet/bin/gem list
 
*** LOCAL GEMS ***
 
geocoder (1.3.3)
typhoeus (1.0.2)

Result:

[root@pe-2017-master ~]# puppet resource package --param provider
package { 'geocoder':
  ensure   => ['1.4.3'],
  provider => 'gem',
}
package { 'trollop':
  ensure   => ['2.0'],
  provider => 'gem',
}
package { 'typhoeus':
  ensure   => ['1.0.2'],
  provider => 'puppet_gem',
}

typhoeus gem is only installed in puppet ruby and is listed
trollop gem is only installed in system ruby and is listed
geocoder gem is installed in puppet and system ruby and only system ruby is listed

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

Thomas Kishel (JIRA)

unread,
May 4, 2017, 3:08:04 PM5/4/17
to puppe...@googlegroups.com
Thomas Kishel commented on Bug PUP-7497
 
Re: puppet resource package command fails to list all packages

Windows:

# SYSTEM RUBY
 
C:\Users\Administrator>gem list
 
*** LOCAL GEMS ***
 
did_you_mean (1.0.0)
sinatra (1.4.8)
 
# PUPPET RUBY
 
C:\Windows\system32>gem list
 
*** LOCAL GEMS ***
 
deep_merge (1.0.1)
sinatra (1.3.1)

Result:

C:\Windows\system32>puppet resource package --param provider
package { 'deep_merge':
  ensure   => ['1.0.1'],
  provider => 'puppet_gem',
}
package { 'did_you_mean':
  ensure   => ['1.0.0'],
  provider => 'gem',
}
package { 'sinatra':
  ensure   => ['1.4.8'],
  provider => 'gem',
}

Thomas Kishel (JIRA)

unread,
May 12, 2017, 3:16:03 PM5/12/17
to puppe...@googlegroups.com
Thomas Kishel updated an issue
 
Change By: Thomas Kishel
h4. Issue:
h4. 

The {{puppet resource package}} command used to list packages
 discards  de-duplicates  identically named resources managed by multiple providers.

This results in an
 inaccurate  incomplete  list of  installed  packages.

h4. Test:
h4. 

{code}
# SYSTEM RUBY

[root@pe-20172nightly-master ~]# gem list

*** LOCAL GEMS ***

geocoder (1.4.3)
trollop (2.0)

# PUPPET RUBY

[root@pe-2017-master ~]# /opt/puppetlabs/puppet/bin/gem list

*** LOCAL GEMS ***

geocoder (1.3.3)
typhoeus (1.0.2)
{code}

Result:

{code}
[root@pe-2017-master ~]# puppet resource package --param provider
package { 'geocoder':
  ensure   => ['1.4.3'],
  provider => 'gem',
}
package { 'trollop':
  ensure   => ['2.0'],
  provider => 'gem',
}
package { 'typhoeus':
  ensure   => ['1.0.2'],
  provider => 'puppet_gem',
}
{code}


typhoeus gem is only installed in puppet ruby and is listed
trollop gem is only installed in system ruby and is listed
geocoder gem is installed in puppet and system ruby and only system ruby is listed

Thomas Kishel (JIRA)

unread,
May 12, 2017, 3:23:02 PM5/12/17
to puppe...@googlegroups.com
Thomas Kishel commented on Bug PUP-7497
 
Re: puppet resource package command fails to list all packages

This issue isn't specific to gem vs puppet_gem providers, it also occurs with gem vs yum providers.

[root@pe-201721-master ~]# gem install zip
 
[root@pe-201721-master ~]# gem list | grep zip
zip (2.0.2)

[root@pe-201721-master ~]# yum install zip
 
[root@pe-201721-master ~]# yum list installed | grep zip
zip.x86_64                     3.0-11.el7                     @base             

[root@pe-201721-master ~]# curl -X GET http://localhost:8080/pdb/query/v4 --data-urlencode \
"query=package_inventory[certname, version, provider]{ package_name = 'zip'}" \
| python -m json.tool
 
[
    {
        "certname": "pe-201721-master.puppetdebug.vlan",
        "provider": "yum",
        "version": "3.0-11.el7"
    }
]

Thomas Kishel (JIRA)

unread,
May 12, 2017, 3:25:02 PM5/12/17
to puppe...@googlegroups.com
Thomas Kishel updated an issue
Change By: Thomas Kishel
h4. Issue:
h4. 

The {{puppet resource package}} command used to list packages de-duplicates identically named resources managed by multiple providers.

This results in an incomplete list of installed packages
, including in the Package Inspector feature released in Puppet Enterprise 2017 . 2.

Thomas Kishel (JIRA)

unread,
May 12, 2017, 3:37:02 PM5/12/17
to puppe...@googlegroups.com

Ruth Linehan (JIRA)

unread,
May 15, 2017, 6:18:06 PM5/15/17
to puppe...@googlegroups.com

Ruth Linehan (JIRA)

unread,
May 15, 2017, 6:23:04 PM5/15/17
to puppe...@googlegroups.com
Ruth Linehan commented on Bug PUP-7497
 
Re: puppet resource package command fails to list all packages

Reproduced this - and in the above example with zip from both yum and gem, puppet resource package has the same incorrect output:

package { 'zip':
  ensure => '3.0-11.el7',
}

with nothing about it from gem.

Thomas Kishel (JIRA)

unread,
Oct 17, 2017, 5:46:03 PM10/17/17
to puppe...@googlegroups.com
Thomas Kishel commented on Bug PUP-7497

Trouble begins right around here: https://github.com/puppetlabs/puppet/blob/master/lib/puppet/type.rb#L1168

Puppet.debug "%s %s found in both %s and %s; skipping the %s version" %

Branan Riley (JIRA)

unread,
May 14, 2018, 3:14:03 PM5/14/18
to puppe...@googlegroups.com
Branan Riley updated an issue
 
Change By: Branan Riley
Labels: cli discovery package type_and_provider
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Branan Riley (JIRA)

unread,
May 14, 2018, 3:15:03 PM5/14/18
to puppe...@googlegroups.com
Branan Riley updated an issue
Change By: Branan Riley
Labels: cli discovery package triaged type_and_provider

Josh Cooper (Jira)

unread,
Jun 11, 2021, 6:31:03 PM6/11/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-7497
 
Re: puppet resource package command fails to list all packages

The problem is the instances method assumes the title is unique across all providers of that type, but the package type supports composite namevars. This patch seems to work, but causes the same package to be reported by both rpm and dnf:

diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 6690a451a7..a55d029c08 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -1187,16 +1187,18 @@ class Type
         # We always want to use the "first" provider instance we find, unless the resource
         # is already managed and has a different provider set
         title = instance.respond_to?(:title) ? instance.title : instance.name
-        other = provider_instances[title]
+        result = new(:name => instance.name, :provider => instance, :title => title)
+        key = result.uniqueness_key.compact.join(':')
+        other = provider_instances[key]
+        puts "KEY #{key}"
         if other
           Puppet.debug {
             "%s %s found in both %s and %s; skipping the %s version" % [self.name.to_s.capitalize, title, other.class.name, instance.class.name, instance.class.name]
           }
           next
         end
-        provider_instances[title] = instance
+        provider_instances[key] = instance
 
-        result = new(:name => instance.name, :provider => instance, :title => title)
         properties.each { |name| result.newattr(name) }
         result
       end

When requesting all packages, it returns all of them, along with the provider parameter:

# puppet resource package
..
package { 'zip':
  ensure   => '3.0-23.el8',
  provider => 'dnf',
}
package { 'zip':
  ensure   => '3.0-23.el8',
  provider => 'rpm',
}
package { 'zip':
  ensure   => ['2.0.2'],
  provider => 'gem',
}
package { 'zip':
  ensure   => ['2.0.2'],
  provider => 'puppet_gem',
}

If you ask for an instance by name without specifying a provider, you'll get one of them. I think it's the one from the default provider:

# puppet resource package zip
package { 'zip':
  ensure   => '3.0-23.el8',
  provider => 'dnf',
}

Or you can ask for an instance by name for a specific provider:

# puppet resource package zip provider=gem
package { 'zip':
  ensure   => ['2.0.2'],
  provider => 'gem',
}

This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages