Bug 175316

Summary: Unexpected behavior with installonlyn plugin when both up and smp kernels are installed
Product: [Fedora] Fedora Reporter: Jef Spaleta <jspaleta>
Component: yumAssignee: Jeremy Katz <katzj>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: katzj, orion
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-02-24 23:33:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 150221    

Description Jef Spaleta 2005-12-08 20:34:07 UTC
Description of problem:
Odd behavior when both smp and up kernels are installed. Running an smp kernel
the installonlyn seems to be triggering the removal of up kernels in an odd
manner. SMP removal is I expect. It seems that when kernel removal is triggered
installonlyn is choosing to remove all up kernels that do not match uname -r
regardless of the value on n, when the installed up and smp kernel versions are
not exactly the same. 

Case 1, Starting state with one less up kernel than smp kernel.
Result: All up kernels not matching uname -r base-version are removed older and
newer

>uname -r
2.6.14-1.1739_FC5smp

>cat installonlyn.conf
[main]
enabled=1
# this sets the number of package versions which are kept
tokeep=4

>rpm -q kernel
kernel-2.6.14-1.1735_FC5
kernel-2.6.14-1.1739_FC5
kernel-2.6.14-1.1740_FC5

>rpm -q kernel-smp
kernel-smp-2.6.14-1.1729_FC5
kernel-smp-2.6.14-1.1735_FC5
kernel-smp-2.6.14-1.1739_FC5
kernel-smp-2.6.14-1.1740_FC5

>yum update "kernel*"
Installing:
 kernel                  i686       2.6.14-1.1743_FC5  development        15 M
 kernel-smp              i686       2.6.14-1.1743_FC5  development        16 M
Removing:
 kernel                  i686       2.6.14-1.1740_FC5  installed          38 M
 kernel                  i686       2.6.14-1.1735_FC5  installed          38 M
 kernel-smp              i686       2.6.14-1.1729_FC5  installed          44 M



Case 2, Starting with same up and smp versions installed.
Result: Only oldest up kernel is selected for removal as expected. 

>rpm -q kernel
kernel-2.6.14-1.1729_FC5
kernel-2.6.14-1.1735_FC5
kernel-2.6.14-1.1739_FC5
kernel-2.6.14-1.1740_FC5

>rpm -q kernel-smp
kernel-smp-2.6.14-1.1729_FC5
kernel-smp-2.6.14-1.1735_FC5
kernel-smp-2.6.14-1.1739_FC5
kernel-smp-2.6.14-1.1740_FC5

>uname -r
2.6.14-1.1739_FC5smp

>yum update 
Installing:
 kernel                  i686       2.6.14-1.1743_FC5  development        15 M
 kernel-smp              i686       2.6.14-1.1743_FC5  development        16 M
Removing:
 kernel                  i686       2.6.14-1.1729_FC5  installed          38 M
 kernel-smp              i686       2.6.14-1.1729_FC5  installed          44 M


How reproducible:
Very I've tested this with several values of tokeep. As soon as you happen to
have the number of installed up and smp kernels mismatch the installonlyn plugin
wants to remove all the up kernels. Of course this isn't a problem for the
default value of tokeep=2. This will only be seen by people who are trying to
keep backup kernels on the system.  I'm looking at the toremove calculation in
the plugin to see if I'm clever enough to patch this non default situation, I
just wanted to file it in case anyone else cared.

-jef

Comment 1 Orion Poplawski 2005-12-09 16:04:52 UTC
Seeing something similar with kernel and kernel-devel:

# cat /etc/yum/pluginconf.d/installonlyn.conf
[main]
enabled=1
# this sets the number of package versions which are kept
tokeep=2

# yum upgrade kernel\*
Loading "installonlyn" plugin
Setting up Upgrade Process
Setting up repositories
Reading repository metadata in from local files
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package kernel.x86_64 0:2.6.14-1.1749_FC5 set to be installed
---> Package kernel-devel.x86_64 0:2.6.14-1.1749_FC5 set to be installed
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 kernel                  x86_64     2.6.14-1.1749_FC5  development        16 M
 kernel-devel            x86_64     2.6.14-1.1749_FC5  development       4.3 M
Removing:
 kernel                  x86_64     2.6.14-1.1740_FC5  installed          84 M
 kernel-devel            x86_64     2.6.14-1.1740_FC5  installed          13 M

Transaction Summary
=============================================================================
Install      2 Package(s)
Update       0 Package(s)
Remove       2 Package(s)

Would have expected installonly to keep the old kernel.

Comment 2 Jef Spaleta 2005-12-09 16:28:38 UTC
You didn't show what you had installed for the kernel and kernel-smp before the
install attempt.

If you have the same number kernel and kernel-smp versions installed before the
operation, then you are similar to my Case 2 and what you see is exactly what I
expect.  Because of the counting invovled, what I am talking about can only be
seen with tokeep=3 or higher and only when the number of kernel and the number
of kernel-smp versions mismatch.  

To be clear  installonlyn with tokeep=2   should keep only keep 2 kernel*
packages on your system. That means 2 kernel and 2 kernel-smp and so on for
kernel-devel and kernel-smp-devel as well.

-jef

Comment 3 Orion Poplawski 2005-12-09 16:32:54 UTC
Before the upgrade I have only 1 kernel and 1 kernel-devel.  I guess my naive
assumption would be that tokeep=2 would keep two bootable kernels.  Since
kernel-devel is not a bootable kernel I would expect it to be excluded.  So
perhaps it is a different bug?

Comment 4 Jeremy Katz 2005-12-14 03:44:24 UTC
installyonlyn deals with _all_ installonly packages including kernel-devel.

Jef -- what you're seeing is a side effect of how I implemented the "don't
remove the running kernel" stuff.

Comment 5 Jef Spaleta 2005-12-14 04:02:59 UTC
Yeah I see exactly how what I'm seeing is happening I just haven't found the
time to attempt a sane patch that makes the side effect go away for the oddball
case my system wandered into.   Maybe this weekend I'll be able to poke at this
and submit a patch.

-jef

Comment 6 Jeremy Katz 2006-02-24 23:33:59 UTC
Okay, this looks to be saner with the fix for bug 176704.

[root@dhcp150 ~]# rpm -q kernel
kernel-2.6.15-1.1948_FC5
kernel-2.6.15-1.1955_FC5
kernel-2.6.15-1.1953_FC5
kernel-2.6.15-1.1936_FC5
[root@dhcp150 ~]# rpm -q kernel-smp
kernel-smp-2.6.15-1.1955_FC5
kernel-smp-2.6.15-1.1953_FC5
kernel-smp-2.6.15-1.1948_FC5
kernel-smp-2.6.15-1.1936_FC5
kernel-smp-2.6.15-1.1933_FC5
[root@dhcp150 ~]# cat /etc/yum/pluginconf.d/installonlyn.conf
[main]
enabled=1
# this sets the number of package versions which are kept
tokeep=5

[root@dhcp150 ~]# yum update 'kernel*'
...
=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 kernel                  i686       2.6.15-1.1977_FC5  development        13 M
 kernel-smp              i686       2.6.15-1.1977_FC5  development        14 M
Removing:
 kernel-smp              i686       2.6.15-1.1933_FC5  installed          38 M


I'm okay with keeping all kernels of the same "vintage" around since having both
is no longer the default, and even if it were, it doesn't seem _too_ odd to want
to do.