Bug 1173106 - zypper purge-kernels removes packages which shouldn't be removed
zypper purge-kernels removes packages which shouldn't be removed
Status: RESOLVED FIXED
: 1171224 1173371 (view as bug list)
Classification: openSUSE
Product: openSUSE Distribution
Classification: openSUSE
Component: libzypp
Leap 15.2
Other Other
: P3 - Medium : Normal (vote)
: ---
Assigned To: E-mail List
E-mail List
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-06-18 11:25 UTC by Manfred Hollstein
Modified: 2020-08-20 01:14 UTC (History)
10 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
/var/log/zypper.log (903.28 KB, application/gzip)
2020-06-18 16:18 UTC, Manfred Hollstein
Details
gzipped "zypper.log" (614.76 KB, application/gzip)
2020-06-18 19:15 UTC, Neil Rickert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Manfred Hollstein 2020-06-18 11:25:57 UTC
I'm on openSUSE Leap build-ID 685.2 with libzypp-17.23.6-lp152.1.1.x86_64 atm.

Any "zypper dup" or "zypper up" command which involves updating kernel packages results in the removal of all "kernel-default-devel", "kernel-devel", and "kernel-source" packages. I tracked it down to the new "purge-kernels" command of zypper, which on my system currently shows this:

# zypper purge-kernels -D
Reading installed packages...

Preparing to purge obsolete kernels...
Configuration: latest,latest-1,running,oldest
Running kernel release: 5.7.3-1.g44c4af0-default
Running kernel arch: x86_64

Resolving package dependencies...

The following 6 packages are going to be REMOVED:
  kernel-default-devel-5.3.18-lp152.19.2 kernel-default-devel-5.7.3-1.1.g44c4af0
  kernel-devel-5.3.18-lp152.19.2 kernel-devel-5.7.3-1.1.g44c4af0
  kernel-source-5.3.18-lp152.19.2 kernel-source-5.7.3-1.1.g44c4af0

6 packages to remove.
After the operation, 1.7 GiB will be freed.
Continue? [y/n/v/...? shows all options] (y): n

I deliberately chose to have the devel and source packages installed, so why is installing updates removing these packages? This looks wrong to me!
Comment 1 Neil Rickert 2020-06-18 14:45:02 UTC
I can confirm that.  It also happens on Tumbleweed.

I previously reported this on bug 1171224 and reopened that bug.  The fix for that bug is broken.

For now, I have disabled the "purge-kernels" service, and I am manually removing old kernels.
Comment 2 Benjamin Zeller 2020-06-18 15:42:43 UTC
Could you provide the zypper log for the purge-kernels run? 

I have this situation in the testsuite, so there might be something in the metadata that is causing this.
Comment 3 Manfred Hollstein 2020-06-18 16:18:59 UTC
Created attachment 838946 [details]
/var/log/zypper.log

This is my /var/log/zypper.log for the last two days. BUT, I never ran purge-kernels explicitly, but just used "zypper dup" for upgrading from one snapshot to the next one, or "zypper up" to install local updates, like the kernels from Kernel:stable (mirrored to my local Kernel:stable.local repo). As Neil suggested, I have disabled "purge-kernels.service" for now, too; will see what'll happen during the next "zypper dup/up" round next time.
Comment 4 Neil Rickert 2020-06-18 19:15:34 UTC
Created attachment 838951 [details]
gzipped "zypper.log"

I have uploaded "zypper.log.gz" (compressed zypper.log)

The fateful package removals were on June 10.
Comment 5 Manfred Hollstein 2020-06-19 06:28:16 UTC
The issue is actually triggered by each kernel; their installation script touches /boot/do_purge_kernels:

$ rpm -q kernel-default-5.3.18-lp152.19.2.x86_64 --scripts | grep purge
# Flag to trigger /etc/init.d/purge-kernels on next reboot (fate#312018)
touch /boot/do_purge_kernels
rm -f /boot/do_purge_kernels

After the next reboot, zypper purge-kernels then gets called and does its job. However, it should *not* remove the devel and source RPMs!

Until this is fixed in libzypp/zypper, I'll use this recipe:

# systemctl disable purge-kernels.service
# zypper dup
# rm /boot/do_purge_kernels
# reboot
Comment 6 Benjamin Zeller 2020-06-19 06:46:03 UTC
So for some reason zypper thinks there is no kernel with the same version installed
for each of those devel and source packages it is removing. I will try to reproduce that locally in order to figure out
what is breaking here.
Comment 7 Benjamin Zeller 2020-06-19 10:52:12 UTC
So it seems that the kernel packages do not provide their exact version in the metadata, e.g. 

I have kernel 4.12.14-lp151.28.44.1 installed, however in the metadata it only
provides:

kernel = 4.12.14-lp151.28.44

Hence zypper does not realize that its the same package. So it takes down the kernel-devel package, which in turn also removes the kernel-flavour-devel package. 

Seems I need to find a different way to match those together.
Comment 8 Michael Andres 2020-06-26 17:05:42 UTC
*** Bug 1171224 has been marked as a duplicate of this bug. ***
Comment 9 Michael Andres 2020-06-26 17:07:49 UTC
Joining all purge kernel related issues here, as we're going to do a complete review (and probably rewrite). The resulting fix will then be distributed to TW and all CODE.15 products.
Comment 10 Michael Andres 2020-07-01 14:55:45 UTC
*** Bug 1173371 has been marked as a duplicate of this bug. ***
Comment 11 Michal Suchanek 2020-07-01 19:13:06 UTC
Suggested removal procedure

1) find all packages that provide multiversion(kernel)

2) out of these find packages that provide kernel-uname-r, and strip second dash and anything that follows from the package name for the purpose of applying keepspec

3) for each group of packages with the same name apply keepspec, non-matching packages are scheduled for removal

4) for each package that is scheduled for removal also schedule debuginfo and debugsource of the same version for removal

5) determine what additional packages would need to be removed to satisfy dependencies, and schedule additional packages that match autoremove regexp(*)

6) if dependencies cannot be satisfied because some packages that do not match autoremove regexp would have to be removed deschedule removal of some packages (**) Typically a package depending on a KMP that depend on an old kernel version would fall into this category.

*) can be lifted from original perl script

**) Note that with the original perl script some random package providing the dependency would be preserved. With libzypp it should be possible to select highest version that provides the dependency.
Comment 12 Michael Andres 2020-07-02 07:46:32 UTC
Thanks Michal, also for your support in RC. We're about to revisit the whole workflow.
Comment 13 Michael Andres 2020-07-14 11:33:49 UTC
Fix will be available in libzypp-17.24.0.
Comment 18 Swamp Workflow Management 2020-07-16 16:15:29 UTC
SUSE-RU-2020:1938-1: An update that has four recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1169947,1170801,1172925,1173106
CVE References: 
Sources used:
SUSE Linux Enterprise Module for Development Tools 15-SP2 (src):    libsolv-0.7.14-3.3.2
SUSE Linux Enterprise Module for Basesystem 15-SP2 (src):    libsolv-0.7.14-3.3.2, libzypp-17.24.0-3.7.1, zypper-1.14.37-3.3.3

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 20 Swamp Workflow Management 2020-07-20 16:16:29 UTC
openSUSE-RU-2020:1019-1: An update that has four recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1169947,1170801,1172925,1173106
CVE References: 
Sources used:
openSUSE Leap 15.2 (src):    libsolv-0.7.14-lp152.2.3.1, libzypp-17.24.0-lp152.2.3.2, zypper-1.14.37-lp152.2.3.1
Comment 21 Swamp Workflow Management 2020-07-24 16:25:42 UTC
SUSE-RU-2020:2040-1: An update that has 5 recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1170801,1171224,1172135,1173106,1174011
CVE References: 
Sources used:
SUSE Linux Enterprise Module for Packagehub Subpackages 15-SP1 (src):    libsolv-0.7.14-3.22.2
SUSE Linux Enterprise Module for Development Tools 15-SP1 (src):    libsolv-0.7.14-3.22.2
SUSE Linux Enterprise Module for Basesystem 15-SP1 (src):    libsolv-0.7.14-3.22.2, libzypp-17.24.1-3.28.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 22 Swamp Workflow Management 2020-07-28 16:13:18 UTC
openSUSE-RU-2020:1109-1: An update that has 5 recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1170801,1171224,1172135,1173106,1174011
CVE References: 
JIRA References: 
Sources used:
openSUSE Leap 15.1 (src):    libsolv-0.7.14-lp151.2.19.1, libzypp-17.24.1-lp151.2.19.1
Comment 23 Swamp Workflow Management 2020-08-20 01:14:52 UTC
SUSE-RU-2020:2279-1: An update that has two recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1173106,1174011
CVE References: 
JIRA References: 
Sources used:
SUSE Linux Enterprise Server for SAP 15 (src):    libzypp-17.24.1-3.46.1
SUSE Linux Enterprise Server 15-LTSS (src):    libzypp-17.24.1-3.46.1
SUSE Linux Enterprise Installer 15 (src):    libzypp-17.24.1-3.46.1
SUSE Linux Enterprise High Performance Computing 15-LTSS (src):    libzypp-17.24.1-3.46.1
SUSE Linux Enterprise High Performance Computing 15-ESPOS (src):    libzypp-17.24.1-3.46.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.