Jira (PUP-4647) Yum provider uses rpm -e to uninstall packages

26 views
Skip to first unread message

Kike Escorihuela Navarro (JIRA)

unread,
May 22, 2015, 6:25:15 AM5/22/15
to puppe...@googlegroups.com
Kike Escorihuela Navarro created an issue
 
Puppet / Bug PUP-4647
Yum provider uses rpm -e to uninstall packages
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2015/05/22 3:24 AM
Priority: Normal Normal
Reporter: Kike Escorihuela Navarro

class gvpbi::install ($ensure) {

package

{'pdi-gvp-bi-core': require => Class['gvpbibase'], provider => 'yum', install_options => [ '-d5', '-e5' ], ensure => $ensure, }

package

{'pdi-python2.7-numpy': require => Class['gvpbibase'], provider => 'yum', install_options => [ '-d5', '-e5' ], ensure => absent, before => Package['pdi-gvp-bi-core'], }

}

but:

Error: Execution of '/bin/rpm -e pdi-python2.7-numpy-1.8.1-1.x86_64' returned 1: error: Failed dependencies:
pdi-python2.7-numpy is needed by (installed) pdi-gvp-bi-core-3.1.0-175.ga7bcd2c.noarch
Error: /Stage[main]/Gvpbi::Install/Package[pdi-python2.7-numpy]/ensure: change from 1.8.1-1 to absent failed: Execution of '/bin/rpm -e pdi-python2.7-numpy-1.8.1-1.x86_64' returned 1: error: Failed dependencies:
pdi-python2.7-numpy is needed by (installed) pdi-gvp-bi-core-3.1.0-175.ga7bcd2c.noarch

but if I remove the package using yum the dependecies are automatically resolved and unistall the pdi-gvp-bi-core package.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.3.15#6346-sha1:dbc023d)
Atlassian logo

Josh Cooper (JIRA)

unread,
May 16, 2017, 7:40:03 PM5/16/17
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
{code:puppet}
class gvpbi::install ($ensure) {

 package {'pdi-gvp-bi-core':
    require => Class['gvpbibase'],
    provider => 'yum',
    install_options => [ '-d5', '-e5' ],
    ensure  => $ensure,
 }
 package {'pdi-python2.7-numpy':
    require => Class['gvpbibase'],
    provider => 'yum',
    install_options => [ '-d5', '-e5' ],
    ensure  => absent,
    before => Package['pdi-gvp-bi-core'],
 }
}
{code}

but:

{noformat}
Error: Execution of '/bin/rpm -e pdi-python2.7-numpy-1.8.1-1.x86_64' returned 1: error: Failed dependencies:
pdi-python2.7-numpy is needed by (installed) pdi-gvp-bi-core-3.1.0-175.ga7bcd2c.noarch
Error: /Stage[main]/Gvpbi::Install/Package[pdi-python2.7-numpy]/ensure: change from 1.8.1-1 to absent failed: Execution of '/bin/rpm -e pdi-python2.7-numpy-1.8.1-1.x86_64' returned 1: error: Failed dependencies:
pdi-python2.7-numpy is needed by (installed) pdi-gvp-bi-core-3.1.0-175.ga7bcd2c.noarch
{noformat}

but if I remove the package using yum the dependecies are automatically resolved and unistall the pdi-gvp-bi-core package.
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Josh Cooper (JIRA)

unread,
May 16, 2017, 7:54:03 PM5/16/17
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
May 16, 2017, 7:54:03 PM5/16/17
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-4647
 
Re: Yum provider uses rpm -e to uninstall packages

Kike Escorihuela Navarro Is this a duplicate of PUP-2451? Basically when using ensure => absent puppet does not reverse the direction of the dependencies. So due to the before => Package['pdi-gvp-bi-core'], puppet will try to remove pdi-python2.7-numpy before pdi-gvp-bi-core, which fails. Is this a fair characterization of what you're seeing?

Moses Mendoza (JIRA)

unread,
May 18, 2017, 2:00:38 PM5/18/17
to puppe...@googlegroups.com

Thomas Kishel (JIRA)

unread,
Oct 31, 2017, 2:12:03 PM10/31/17
to puppe...@googlegroups.com
Thomas Kishel commented on Bug PUP-4647
 
Re: Yum provider uses rpm -e to uninstall packages

The yum provider uses its own install method (with a yum command) when installing, but uses the inherited uninstall method from the rpm provider (with a rpm command) when uninstalling.

This has the potential to 'corrupt' the yum database, and we have been identified as doing so externally: https://bugzilla.redhat.com/show_bug.cgi?id=973375

I've seen this reported as both rpmdb checksum is invalid and rpmdb altered outside of yum

Could we implement uninstall in the yum provider?

```
  has_feature :uninstall_options
 
  def uninstall
    query if get(:arch) == :absent
    nvr = "#{get(:name)}-#{get(:version)}-#{get(:release)}"
    arch = ".#{get(:arch)}"
    if @resource[:name][-arch.size, arch.size] == arch
      nvr += arch
    else
      nvr += ".#{get(:arch)}"
    end
    command = [command(:cmd)] + ["-d", "0", "-e", 0, "-y", uninstall_options, "erase", nvr].compact
    output = execute(command)
  end
 
  def uninstall_options
    join_options(resource[:uninstall_options])
  end
```

Note that the above is a functional (but uninformed and untested) proof-of-concept.

This message was sent by Atlassian JIRA (v7.0.2#70111-sha1:88534db)
Atlassian logo

Thomas Kishel (JIRA)

unread,
Nov 1, 2017, 1:50:03 PM11/1/17
to puppe...@googlegroups.com
Thomas Kishel commented on Bug PUP-4647

Found ... https://projects.puppetlabs.com/issues/1739

yum package provider should erase packages

The yum package provider currently runs ‘rpm -e PKG’ when it’s told to uninstall something (ensure => absent). To make it possible to uninstall packages with cyclic dependencies, it would be much better to have it run ‘yum -y erase PKG’. Doing that is a lot more dangerous, since it will uninstall PKG and everything that depends on it, but with that danger comes the power that some users need.

https://github.com/puppetlabs/puppet/commit/d5e19f18eddd0d6ddb9818dabc873b3203335f95

otheus (JIRA)

unread,
Mar 23, 2019, 5:10:04 PM3/23/19
to puppe...@googlegroups.com
otheus commented on Bug PUP-4647

Moreover, this is needed because (1) it's expected behavior, and (2) otherwise the puppet-coder must build in cyclical dependencies in his package list.

Consider:

 

package { 'npm' : ensure => installed }

This will translate to:

 

yum install npm

 

will install npm and nodejs. Now consider the coder needs to specify both:

 

package { 'npm' : ensure => $ensure }
package { nodejs': ensure => $ensure } 

What's the proper dependency here? For installation, npm requires nodejs, but for deinstallation, rpm -e will refuse to remove nodejs as long as npm still exists. And vice-versa! nodejs depends by npm: packages can have circular dependencies, but puppet by design disallows that.

Other than redesigning puppet to handle circular dependencies, better to let the package managers act as they are designed to.

(Note: if puppet could detect a circular dependency, then with the example of rpm and yum, it could try to remove both at the same time. But I think I chose a poor example.)

This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Trevor Vaughan (JIRA)

unread,
Jul 20, 2019, 6:35:02 PM7/20/19
to puppe...@googlegroups.com

This is still an issue. Discovered when attempting to remove `yp-tools` and `ypbind`

Trevor Vaughan (JIRA)

unread,
Jul 25, 2019, 10:08:03 PM7/25/19
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Oct 1, 2019, 1:08:05 AM10/1/19
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Team: Night's Watch

Austin Boyd (Jira)

unread,
Sep 22, 2020, 7:04:04 AM9/22/20
to puppe...@googlegroups.com
Austin Boyd updated an issue
Change By: Austin Boyd
Zendesk Ticket Count: 1
Zendesk Ticket IDs: 27935
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Bogdan Irimie (Jira)

unread,
Nov 5, 2020, 3:51:05 AM11/5/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Nov 5, 2020, 3:52:04 AM11/5/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ready for triage

Ciprian Badescu (Jira)

unread,
Oct 7, 2021, 5:25:02 AM10/7/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Labels: needs_repro package type_and_provider
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Sean Millichamp (Jira)

unread,
Oct 8, 2021, 8:17:04 AM10/8/21
to puppe...@googlegroups.com
Sean Millichamp commented on Bug PUP-4647
 
Re: Yum provider uses rpm -e to uninstall packages

I just came across this ticket and I wanted to add the the documentation specific to the yum provider documents (and has for years) that ensure => absent will not remove dependent packages. For better or for worse, this is a behavior that I have come to rely on as a default for safety reasons, opting to use ensure => purged only when I have done more extensive testing to validate that it is safe and necessary for a particular package.

Latest yum provider docs: https://puppet.com/docs/puppet/7/types/package.html#package-provider-yum
All the way back to 5.5: https://puppet.com/docs/puppet/5.5/types/package.html

I would very much like if Puppet was able to batch up a series of packages and run an "rpm -e" with the whole set, but I realize the current resource/provider design makes that challenging.

When I need to remove a cyclical dependency then I opt into ensure => purged or, if I don't want to risk unknown/unexpected dependencies from being also removed, I'll use an exec. Not the most elegant, but it suffices.

If this behavior does change, I'm not exactly opposed, but it definitely would need to be on a major version as I'd have to reassess every package resource in my environment where I might use absent so I could explicitly specify the rpm provider.

Ciprian Badescu (Jira)

unread,
Oct 20, 2021, 5:19:02 AM10/20/21
to puppe...@googlegroups.com

Since as a user there is an option to use yum to uninstall packages (with ensure => purged), this should satisfy most of use cases.

 

Ciprian Badescu (Jira)

unread,
Oct 20, 2021, 5:20:02 AM10/20/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Labels: needs_repro package type_and_provider

Ciprian Badescu (Jira)

unread,
Oct 26, 2021, 6:46:01 AM10/26/21
to puppe...@googlegroups.com
Ciprian Badescu updated an issue
Change By: Ciprian Badescu
Sprint: ready for triage

Josh Cooper (Jira)

unread,
Nov 11, 2021, 1:39:02 PM11/11/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-4647
 
Re: Yum provider uses rpm -e to uninstall packages

Given the yp-tools and ypbind example, purged does remove the dependencies of the package as well. So we can install both:

# rpm -q yp-tools ypbind
package yp-tools is not installed
package ypbind is not installed
# puppet apply -e "package { 'yp-tools' : ensure => installed }"
Notice: Compiled catalog for XXX in environment production in 0.29 seconds
Notice: /Stage[main]/Main/Package[yp-tools]/ensure: created
Notice: Applied catalog in 1.33 seconds
# rpm -q yp-tools ypbind
yp-tools-2.14-5.el7.x86_64
ypbind-1.37.1-9.el7.x86_64

And erase/purge them them:

# puppet apply -e "package { 'yp-tools' : ensure => purged }" --debug
...
Debug: Executing: '/usr/bin/yum -y erase yp-tools'
Notice: /Stage[main]/Main/Package[yp-tools]/ensure: purged
...
# rpm -q yp-tools ypbind
package yp-tools is not installed
package ypbind is not installed

So I'm going to close this. Please reopen if I'm missing something.

otheus (Jira)

unread,
Jun 6, 2022, 11:39:02 AM6/6/22
to puppe...@googlegroups.com
otheus commented on Bug PUP-4647

josh Hi. I think this issue should be re-opened. (1) purged is doing something other than documented by the type,  (2) I thought there was a dependency problem as well, but currently forgetting and unable to reproduce, and (3) it depends on the site-configuration of yum. For instance, if in yum.conf either option is set:

clean_requirements_on_remove=no
remove_leaf_only=yes

You won't see your expected behavior. 

 

For this reason, I created a new provider (for backwards compatibility) to do it this way:

Puppet::Type.type(:package).provide :yumx, :parent => :yum do
  desc "Support via `yum` with better removal support.
  ...
 
  "
 
  def uninstall
    cmd = :rpm
    opts = []
    query if get(:arch) == :absent
    nvr = "#\{get(:name)}-#\{get(:version)}-#\{get(:release)}"
    arch = ".#\{get(:arch)}"
 
    # If they specified an arch in the manifest, erase that Otherwise,
    # erase the arch we got back from the query. If multiple arches are
    # installed and only the package name is specified (without the
    # arch), this will uninstall all of them on successive runs of the
    # client, one after the other
 
    # version of RPM prior to 4.2.1 can't accept the architecture as
    # part of the package name.
    unless Puppet::Util::Package.versioncmp(self.class.current_version, '4.2.1') < 0
      if @resource[:name][-arch.size, arch.size] == arch
        nvr += arch
      else
        nvr += ".#\{get(:arch)}"
      end
    end
 
    if scan_options(resource[:uninstall_options], 'purge')
      do_purge=true
    end
 
    if do_purge
      opts << "-y"
      opts << "erase"
      opts << "--setopt=clean_requirements_on_remove=yes"
      opts << "--setopt=remove_leaf_only=no"
      yumx opts, nvr
      # The output of this command could be parse to, for instance
      # set the :absent state on dependencies which were marked for
      # removal in the catalog.
      # If they were marked 'present', then print out a warning
    else
      if ! rpm '-q',nvr
        Puppet.warning("#\{self.class}: #\{@resouce[:name]} had already been removed.")
        true
      else
        rpm '-e', nvr
      end
    end
  end  private  # See  yum's scan_options
  def scan_options(options, key)
    return [] if options.nil?
    options.inject([]) do |repos, opt|
      if opt.is_a? Hash and opt[key]
        repos << opt[key]
      end
      repos
    end
  end
end

 

Example:

  package { dont_want:  ensure => absent, uninstall_options => 'purge', provider => yumx }

 

This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages