Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1549178

Summary: Cannot uninstall kmod-kvdo RPM if modules are not loaded
Product: Red Hat Enterprise Linux 7 Reporter: Andy Walsh <awalsh>
Component: kmod-kvdoAssignee: Andy Walsh <awalsh>
Status: CLOSED ERRATA QA Contact: Jakub Krysl <jkrysl>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.5CC: awalsh, bgurney, jkrysl, rhandlin
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 6.1.0.153 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 16:27:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Mock configuration to store at /etc/mock/rhel-7.5-x86_64.cfg none

Description Andy Walsh 2018-02-26 15:40:04 UTC
Created attachment 1400869 [details]
Mock configuration to store at /etc/mock/rhel-7.5-x86_64.cfg

Description of problem:
The RPM contains inside the %preun section two 'modprobe -r' operations, one for each of the kvdo and uds modules.  If you attempt to install the RPM on a system that cannot load the modules for some reason (inside a chroot, for example), then you cannot uninstall the RPM.

from kvdo.spec:
  %preun                                                                                                                                                                                                                                        
  rpm -ql kmod-kvdo-%{kmod_driver_version}-%{kmod_rpm_release}%{?dist}.$(arch) | grep '\.ko$' > /var/run/rpm-kmod-%{kmod_name}-modules                                                                                                          
  modprobe -r kvdo                                                                                                                                                                                                                              
  modprobe -r uds 

Version-Release number of selected component (if applicable):
6.1.0.149-13
Specifically when running on a kABI incompatible host (like a RHEL-7.3 host with mock generating a RHEL-7.5 chroot)

How reproducible:
100%

Steps to Reproduce:
Base machine *must* be on an incompatible kernel (rhel-7.4 or below, or another distro that is not kABI compatible)

Install epel
  sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Install mock
  sudo yum install -y mock
Mount 7.5 DVD
  sudo mkdir -p /mnt/DVD
  sudo mount -o loop /path/to/RHEL-7.5-DVD.iso /mnt/DVD
Create mock definition at /etc/mock/rhel-7.5-x86_64.cfg (Attached)
  
Initialize Mock environment:
  sudo mock -r /etc/mock/rhel-7.5-x86_64.cfg init

Enter the shell for the mock environment and attempt to uninstall the vdo and kmod-kvdo RPMs:
  sudo mock -r /etc/mock/rhel-7.5-x86_64.cfg shell
Confirm VDO is installed inside the shell:
  <mock-chroot> sh-4.2# rpm -qa | grep vdo
Attempt to uninstall kmod-kvdo inside the shell:
  <mock-chroot> sh-4.2# yum remove vdo kmod-kvdo

Witness the failure:
<mock-chroot> sh-4.2# yum remove vdo kmod-kvdo
...snip...
Running transaction
Removed /etc/systemd/system/multi-user.target.wants/vdo.service.
  Erasing    : vdo-6.1.0.149-16.x86_64                                                                                                                                                                                                    1/2 
error: %preun(kmod-kvdo-6.1.0.149-13.el7.x86_64) scriptlet failed, exit status 1
Error in PREUN scriptlet in rpm package kmod-kvdo-6.1.0.149-13.el7.x86_64
  Verifying  : kmod-kvdo-6.1.0.149-13.el7.x86_64                                                                                                                                                                                          1/2 
  Verifying  : vdo-6.1.0.149-16.x86_64                                                                                                                                                                                                    2/2 

Removed:
  vdo.x86_64 0:6.1.0.149-16                                                                                                                                                                                                                   

Failed:
  kmod-kvdo.x86_64 0:6.1.0.149-13.el7                                                                                                                                                                                                         

Complete!


Actual results:
kmod-kvdo RPM is not removed 


Expected results:
kmod-kvdo RPM is removed regardless of error

Additional info:
Very important!  Base machine *must* be on an incompatible kernel (rhel-7.4 or below, or another distro that is not kABI compatible)

Comment 2 Andy Walsh 2018-02-26 17:46:24 UTC
I have a proposed fix that I am testing right now.

I installed the updated package into the mock environment and then removed it successfully.  Here is the output:

[awalsh@awalsh ~]$ sudo mock -r /etc/mock/rhel-7.5-x86_64.cfg --install kmod-kvdo-6.1.0.149-14.el7.x86_64.rpm
INFO: mock.py version 1.4.8 starting (python version = 2.7.5)...
Start: init plugins
INFO: selinux disabled
Finish: init plugins
Start: run
Start: chroot init
INFO: calling preinit hooks
INFO: enabled root cache
INFO: enabled yum cache
Start: cleaning yum metadata
Finish: cleaning yum metadata
INFO: enabled HW Info plugin
Mock Version: 1.4.8
INFO: Mock Version: 1.4.8
Finish: chroot init
INFO: installing package(s): kmod-kvdo-6.1.0.149-14.el7.x86_64.rpm
Failed to set locale, defaulting to C
Examining kmod-kvdo-6.1.0.149-14.el7.x86_64.rpm: kmod-kvdo-6.1.0.149-14.el7.x86_64
Marking kmod-kvdo-6.1.0.149-14.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package kmod-kvdo.x86_64 0:6.1.0.149-14.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================
 Package                                           Arch                                           Version                                                    Repository                                                                  Size
==============================================================================================================================================================================================================================================
Installing:
 kmod-kvdo                                         x86_64                                         6.1.0.149-14.el7                                           /kmod-kvdo-6.1.0.149-14.el7.x86_64                                         1.2 M

Transaction Summary
==============================================================================================================================================================================================================================================
Install  1 Package

Total size: 1.2 M
Installed size: 1.2 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kmod-kvdo-6.1.0.149-14.el7.x86_64                                                                                                                                                                                          1/1 
/sbin/dracut: line 655: warning: setlocale: LC_MESSAGES: cannot change locale ()
/sbin/dracut: line 655: warning: setlocale: LC_MESSAGES: cannot change locale ()
No '/dev/log' or 'logger' included for syslog logging
Turning off host-only mode: '/run' is not mounted!
Turning off host-only mode: '/dev' is not mounted!
  Verifying  : kmod-kvdo-6.1.0.149-14.el7.x86_64                                                                                                                                                                                          1/1 

Installed:
  kmod-kvdo.x86_64 0:6.1.0.149-14.el7                                                                                                                                                                                                         

Complete!
INFO: None
Finish: run

And then the remove:
<mock-chroot> sh-4.2# rpm -qa | grep vdo
kmod-kvdo-6.1.0.149-14.el7.x86_64
<mock-chroot> sh-4.2# yum remove kmod-kvdo
Resolving Dependencies
--> Running transaction check
---> Package kmod-kvdo.x86_64 0:6.1.0.149-14.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================
 Package                                                 Arch                                                 Version                                                           Repository                                               Size
==============================================================================================================================================================================================================================================
Removing:
 kmod-kvdo                                               x86_64                                               6.1.0.149-14.el7                                                  installed                                               1.2 M

Transaction Summary
==============================================================================================================================================================================================================================================
Remove  1 Package

Installed size: 1.2 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : kmod-kvdo-6.1.0.149-14.el7.x86_64                                                                                                                                                                                          1/1 
No '/dev/log' or 'logger' included for syslog logging
mknod: '/var/tmp/dracut.0NX0Np/initramfs/dev/kmsg': Operation not permitted
mknod: '/var/tmp/dracut.0NX0Np/initramfs/dev/console': Operation not permitted
  Verifying  : kmod-kvdo-6.1.0.149-14.el7.x86_64                                                                                                                                                                                          1/1 

Removed:
  kmod-kvdo.x86_64 0:6.1.0.149-14.el7                                                                                                                                                                                                         

Complete!

Comment 3 Andy Walsh 2018-02-26 17:49:05 UTC
I now just need to test and confirm that the previous behavior that worked appropriately still does the same.

Proposed fix is to change from:
  %preun
  rpm -ql kmod-kvdo-%{kmod_driver_version}-%{kmod_rpm_release}%{?dist}.$(arch) | grep '\.ko$' > /var/run/rpm-kmod-%{kmod_name}-modules
  modprobe -r kvdo
  modprobe -r uds

To the following:
  %preun
  for module in kvdo uds; do
    if grep -q ${module} /proc/modules; then
      modprobe -r ${module}
    fi
  done

Comment 4 Andy Walsh 2018-02-26 18:11:14 UTC
Ok, testing works as expected on a VM.

Installed successfully:
  [vagrant@localhost ~]$ sudo yum install -y kmod-kvdo-6.1.0.149-14.el7.x86_64.rpm
  Loaded plugins: product-id, search-disabled-repos, subscription-manager
  This system is not registered with an entitlement server. You can use subscription-manager to register.
  Examining kmod-kvdo-6.1.0.149-14.el7.x86_64.rpm: kmod-kvdo-6.1.0.149-14.el7.x86_64
  Marking kmod-kvdo-6.1.0.149-14.el7.x86_64.rpm to be installed
  Resolving Dependencies
  --> Running transaction check
  ---> Package kmod-kvdo.x86_64 0:6.1.0.149-14.el7 will be installed
  --> Finished Dependency Resolution

  Dependencies Resolved

  ==============================================================================================================================================================================================================================================
   Package                                           Arch                                           Version                                                    Repository                                                                  Size
  ==============================================================================================================================================================================================================================================
  Installing:
   kmod-kvdo                                         x86_64                                         6.1.0.149-14.el7                                           /kmod-kvdo-6.1.0.149-14.el7.x86_64                                         1.2 M

  Transaction Summary
  ==============================================================================================================================================================================================================================================
  Install  1 Package

  Total size: 1.2 M
  Installed size: 1.2 M
  Downloading packages:
  Running transaction check
  Running transaction test
  Transaction test succeeded
  Running transaction
    Installing : kmod-kvdo-6.1.0.149-14.el7.x86_64                                                                                                                                                                                          1/1
    Verifying  : kmod-kvdo-6.1.0.149-14.el7.x86_64                                                                                                                                                                                          1/1

  Installed:
    kmod-kvdo.x86_64 0:6.1.0.149-14.el7

  Complete!

Removed successfully with modules not loaded via modprobe:
  [vagrant@localhost ~]$ sudo yum remove -y kmod-kvdo
  Loaded plugins: product-id, search-disabled-repos, subscription-manager
  This system is not registered with an entitlement server. You can use subscription-manager to register.
  Resolving Dependencies
  --> Running transaction check
  ---> Package kmod-kvdo.x86_64 0:6.1.0.149-14.el7 will be erased
  --> Finished Dependency Resolution

  Dependencies Resolved

  ==============================================================================================================================================================================================================================================
   Package                                                 Arch                                                 Version                                                           Repository                                               Size
  ==============================================================================================================================================================================================================================================
  Removing:
   kmod-kvdo                                               x86_64                                               6.1.0.149-14.el7                                                  installed                                               1.2 M

  Transaction Summary
  ==============================================================================================================================================================================================================================================
  Remove  1 Package

  Installed size: 1.2 M
  Downloading packages:
  Running transaction check
  Running transaction test
  Transaction test succeeded
  Running transaction
    Erasing    : kmod-kvdo-6.1.0.149-14.el7.x86_64                                                                                                                                                                                          1/1
    Verifying  : kmod-kvdo-6.1.0.149-14.el7.x86_64                                                                                                                                                                                          1/1

  Removed:
    kmod-kvdo.x86_64 0:6.1.0.149-14.el7

  Complete!

Uninstalls successfully and unloads the modules when able:
  [vagrant@localhost ~]$ sudo modprobe kvdo                                                                                                                                                                                           [127/5528]
  [vagrant@localhost ~]$ lsmod | egrep 'kvdo|uds'
  kvdo                  493159  0
  uds                   270825  1 kvdo
  dm_mod                123942  12 kvdo,dm_log,dm_mirror
  [vagrant@localhost ~]$ sudo yum remove -y kmod-kvdo
  Loaded plugins: product-id, search-disabled-repos, subscription-manager
  This system is not registered with an entitlement server. You can use subscription-manager to register.
  Resolving Dependencies
  --> Running transaction check
  ---> Package kmod-kvdo.x86_64 0:6.1.0.149-14.el7 will be erased
  --> Finished Dependency Resolution

  Dependencies Resolved

  ==============================================================================================================================================================================================================================================
   Package                                                 Arch                                                 Version                                                           Repository                                               Size
  ==============================================================================================================================================================================================================================================
  Removing:
   kmod-kvdo                                               x86_64                                               6.1.0.149-14.el7                                                  installed                                               1.2 M

  Transaction Summary
  ==============================================================================================================================================================================================================================================
  Remove  1 Package

  Installed size: 1.2 M
  Downloading packages:
  Running transaction check
  Running transaction test
  Transaction test succeeded
  Running transaction
    Erasing    : kmod-kvdo-6.1.0.149-14.el7.x86_64                                                                                                                                                                                          1/1
    Verifying  : kmod-kvdo-6.1.0.149-14.el7.x86_64                                                                                                                                                                                          1/1

  Removed:
    kmod-kvdo.x86_64 0:6.1.0.149-14.el7

  Complete!

And it also fails to remove (as expected) when the modules are unable to be unloaded (there's a running VDO volume):
  [vagrant@localhost ~]$ lsblk
  NAME                                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
  vda                                       252:0    0   64G  0 disk
  ├─vda1                                    252:1    0    1G  0 part /boot
  └─vda2                                    252:2    0   63G  0 part
    ├─rhel_ibm--p8--kvm--03--guest--02-root 253:0    0 41.7G  0 lvm  /
    ├─rhel_ibm--p8--kvm--03--guest--02-swap 253:1    0    1G  0 lvm  [SWAP]
    └─rhel_ibm--p8--kvm--03--guest--02-home 253:2    0 20.3G  0 lvm  /home
  vdb                                       252:16   0   20G  0 disk
  [vagrant@localhost ~]$ sudo vdo create --name vdo0 --device /dev/vdb
  Creating VDO vdo0
  Starting VDO vdo0
  Starting compression on VDO vdo0
  VDO instance 0 volume is ready at /dev/mapper/vdo0
  [vagrant@localhost ~]$ sudo yum remove -y kmod-kvdo
  Loaded plugins: product-id, search-disabled-repos, subscription-manager
  This system is not registered with an entitlement server. You can use subscription-manager to register.
  Resolving Dependencies
  --> Running transaction check
  ---> Package kmod-kvdo.x86_64 0:6.1.0.149-14.el7 will be erased
  --> Processing Dependency: kmod-kvdo >= 6.1 for package: vdo-6.1.0.149-16.x86_64
  --> Running transaction check
  ---> Package vdo.x86_64 0:6.1.0.149-16 will be erased
  --> Finished Dependency Resolution

  Dependencies Resolved

  ==============================================================================================================================================================================================================================================
   Package                                                 Arch                                                 Version                                                           Repository                                               Size
  ==============================================================================================================================================================================================================================================
  Removing:
   kmod-kvdo                                               x86_64                                               6.1.0.149-14.el7                                                  installed                                               1.2 M
  Removing for dependencies:
   vdo                                                     x86_64                                               6.1.0.149-16                                                      @rhel-dvd                                               3.6 M

  Transaction Summary
  ==============================================================================================================================================================================================================================================
  Remove  1 Package (+1 Dependent package)

  Installed size: 4.8 M
  Downloading packages:
  Running transaction check
  Running transaction test
  Transaction test succeeded
  Running transaction
  Removed symlink /etc/systemd/system/multi-user.target.wants/vdo.service.
    Erasing    : vdo-6.1.0.149-16.x86_64                                                                                                                                                                                                    1/2
  modprobe: FATAL: Module kvdo is in use.
  modprobe: FATAL: Module uds is in use.
  error: %preun(kmod-kvdo-6.1.0.149-14.el7.x86_64) scriptlet failed, exit status 1
  Error in PREUN scriptlet in rpm package kmod-kvdo-6.1.0.149-14.el7.x86_64
    Verifying  : vdo-6.1.0.149-16.x86_64                                                                                                                                                                                                    1/2
    Verifying  : kmod-kvdo-6.1.0.149-14.el7.x86_64                                                                                                                                                                                          2/2

  Dependency Removed:
    vdo.x86_64 0:6.1.0.149-16

  Failed:
    kmod-kvdo.x86_64 0:6.1.0.149-14.el7

  Complete!


I will now be working to submit the changes and get another push available to the 7.5 install and github.

Comment 5 Andy Walsh 2018-02-26 20:12:43 UTC
Fixed using the change suggested above *except* the grep string is now "^${module}" to make sure we don't inadvertently match something other than the module we care about.

Comment 7 Jakub Krysl 2018-02-28 11:30:40 UTC
With version kmod-kvdo-6.1.0.153-15 I am able to uninstall this rpm under chroot now. Found no issues without chroot.

Comment 9 Jakub Krysl 2018-03-01 10:35:51 UTC
xni@ found a wrokaround for this bug, leaving it here in case someone needs it:
# rpm -e kmod-kvdo --noscripts

Comment 11 errata-xmlrpc 2018-04-10 16:27:17 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2018:0900