Can't remove packages with zypper

Can’t remove this packages

> zypper search -i | grep kube
S | Name | Summary | Type
—±---------------------±-----------------------------------------------±-------
i+ | kubernetes-apiserver | Kubernetes apiserver for container image | package
i+ | kubernetes-client | Kubernetes client tools | package
i+ | kubernetes-coredns | Kubernetes coredns daemon for container images | package
i+ | kubernetes-etcd | Kubernetes etcd daemon for container images | package
i+ | kubernetes-kubeadm | Kubernetes kubeadm bootstrapping tool | package
i+ | kubernetes-kubelet | Kubernetes kubelet daemon | package
i+ | kubernetes-proxy | Kubernetes proxy for container image | package

They reference other packages, when I do a verify it tries to install missing dependincies.

> zypper verify
Loading repository data…
Reading installed packages…

The following 9 NEW packages are going to be installed:
cri-o-kubeadm-criconfig kubernetes1.22-kubelet kubernetes1.23-apiserver kubernetes1.23-client kubernetes1.23-client-common kubernetes1.23-kubeadm kubernetes1.23-kubelet kubernetes1.23-kubelet-common kubernetes1.23-proxy

and it succeeds. the problem is that if I try to remove them I get this

> zypper remove $(zypper search -i | grep kube | awk -F’|’ ‘{print $2}’)
Reading installed packages…
Resolving package dependencies…

The following 7 packages are going to be REMOVED:
kubernetes-apiserver kubernetes-client kubernetes-coredns kubernetes-etcd kubernetes-kubeadm kubernetes-kubelet kubernetes-proxy

7 packages to remove.
After the operation, 574.0 B will be freed.
Continue? [y/n/v/…? shows all options] (y): y
error: package kubernetes-apiserver-1.23.0-22.3.x86_64 is not installed
(1/7) Removing kubernetes-apiserver-1.23.0-22.3.x86_64 …[error]
Removal of (215)kubernetes-apiserver-1.23.0-22.3.x86_64(@System) failed:
Error: Subprocess failed. Error: RPM failed: Command exited with status 1.

I tried with rpm but no packages are actually installed

> rpm -qa | grep kube
>

How do I remove those?

Just a “you never know if it helps”:

zypper clean
zypper ref

Show output of

ls -l /var/lib/rpm
ls -l /usr/lib/sysimage/rpm

That didn’t help

> ls -l /var/lib/rpm
lrwxrwxrwx 1 root root 26 Mar 11 22:10 /var/lib/rpm -> …/…/usr/lib/sysimage/rpm
> ls -l /usr/lib/sysimage/rpm
total 87236
-rw-r–r-- 1 root root 0 Mar 11 22:03 .rpm.lock
-rw-r–r-- 1 root root 19619840 Mar 14 17:54 Index.db
-rw-r–r-- 1 root root 69709184 Mar 14 17:54 Packages.db

Always use tags [noparse]

...

[/noparse] around computer text.

How did you manage to get this state? All listed packages are virtual; they do not install any files and only contain requirement for versioned kubernetes packages (like kerbernetes1.23-apiserver). You simply cannot install kubernetes-apiserver alone (well, you can, but you must try hard and it is impossible to do by accident).

zypper verify
Loading repository data…
Reading installed packages…

The following 9 NEW packages are going to be installed:
cri-o-kubeadm-criconfig kubernetes1.22-kubelet kubernetes1.23-apiserver kubernetes1.23-client kubernetes1.23-client-common kubernetes1.23-kubeadm kubernetes1.23-kubelet kubernetes1.23-kubelet-common kubernetes1.23-proxy

and it succeeds.

Really? How do you know it? We have no way to tell whether it succeed or not without seeing actual output, but according to

zypper remove $(zypper search -i | grep kube | awk -F’|’ ‘{print $2}’)
Reading installed packages…
Resolving package dependencies…

The following 7 packages are going to be REMOVED:

You still have the same 7 packages, not 16 as expected, so nothing have been installed.

Something was wrong at the very beginning.

Start with showing

rpm -qa kube\*
zypper se -si '/^kube/'

Always show full command invocation and its output including subsequent prompt so we know output is complete. Do not type, copy and paste.

It simply deletes downloaded packages from cache. It hardly can affect what packages zypper believes are nistalled.

Try zypper clean --all.


 root  ~  zypper se -si '/^kube/'
Loading repository data...
Reading installed packages...


S  | Name                 | Type    | Version     | Arch   | Repository
---+----------------------+---------+-------------+--------+----------------------
i+ | kubernetes-apiserver | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-apiserver | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-client    | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-client    | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-coredns   | package | 1.8.6-22.3  | x86_64 | Main Repository (OSS)
i+ | kubernetes-coredns   | package | 1.8.6-22.3  | x86_64 | openSUSE-20220310-0
i+ | kubernetes-etcd      | package | 3.5.1-22.3  | x86_64 | Main Repository (OSS)
i+ | kubernetes-etcd      | package | 3.5.1-22.3  | x86_64 | openSUSE-20220310-0
i+ | kubernetes-kubeadm   | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-kubeadm   | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-kubelet   | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-kubelet   | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-proxy     | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-proxy     | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0

[/noparse]

As I didn’t paste the other command with full out put and did it without code tags (sorry just new around here :)) here it goes

When I do verify


 root  ~  zypper verify
Retrieving repository 'Main Repository (NON-OSS)' metadata .............................................................................................................................................................................................[done]
Building repository 'Main Repository (NON-OSS)' cache ..................................................................................................................................................................................................[done]
Retrieving repository 'Main Repository (OSS)' metadata .................................................................................................................................................................................................[done]
Building repository 'Main Repository (OSS)' cache ......................................................................................................................................................................................................[done]
Retrieving repository 'openSUSE-20220310-0' metadata ...................................................................................................................................................................................................[done]
Building repository 'openSUSE-20220310-0' cache ........................................................................................................................................................................................................[done]
Loading repository data...
Reading installed packages...


The following 9 NEW packages are going to be installed:
  cri-o-kubeadm-criconfig kubernetes1.22-kubelet kubernetes1.23-apiserver kubernetes1.23-client kubernetes1.23-client-common kubernetes1.23-kubeadm kubernetes1.23-kubelet kubernetes1.23-kubelet-common kubernetes1.23-proxy


9 new packages to install.
Overall download size: 106.0 MiB. Already cached: 0 B. After the operation, additional 624.0 MiB will be used.
Some of the dependencies of installed packages are broken. In order to fix these dependencies, the following actions need to be taken:
Continue? [y/n/v/...? shows all options] (y): y
Retrieving package kubernetes1.23-apiserver-1.23.0-3.2.x86_64                                                                                                                                                            (1/9),  25.9 MiB (161.5 MiB unpacked)
Retrieving: kubernetes1.23-apiserver-1.23.0-3.2.x86_64.rpm .................................................................................................................................................................................[done (9.6 MiB/s)]
Retrieving package kubernetes1.23-client-1.23.0-3.2.x86_64                                                                                                                                                               (2/9),  10.7 MiB ( 55.2 MiB unpacked)
Retrieving: kubernetes1.23-client-1.23.0-3.2.x86_64.rpm ....................................................................................................................................................................................[done (8.9 MiB/s)]
Retrieving package kubernetes1.23-kubelet-1.23.0-3.2.x86_64                                                                                                                                                              (3/9),  24.7 MiB (154.2 MiB unpacked)
Retrieving: kubernetes1.23-kubelet-1.23.0-3.2.x86_64.rpm ...................................................................................................................................................................................[done (9.1 MiB/s)]
Retrieving package kubernetes1.23-proxy-1.23.0-3.2.x86_64                                                                                                                                                                (4/9),   9.9 MiB ( 53.0 MiB unpacked)
Retrieving: kubernetes1.23-proxy-1.23.0-3.2.x86_64.rpm .....................................................................................................................................................................................[done (5.9 MiB/s)]
Retrieving package kubernetes1.23-client-common-1.23.0-3.2.x86_64                                                                                                                                                        (5/9), 242.4 KiB (627.6 KiB unpacked)
Retrieving: kubernetes1.23-client-common-1.23.0-3.2.x86_64.rpm .........................................................................................................................................................................................[done]
Retrieving package kubernetes1.23-kubelet-common-1.23.0-3.2.x86_64                                                                                                                                                       (6/9),  56.9 KiB (147.3 KiB unpacked)
Retrieving: kubernetes1.23-kubelet-common-1.23.0-3.2.x86_64.rpm ........................................................................................................................................................................................[done]
Retrieving package kubernetes1.22-kubelet-1.22.4-2.4.x86_64                                                                                                                                                              (7/9),  23.7 MiB (145.0 MiB unpacked)
Retrieving: kubernetes1.22-kubelet-1.22.4-2.4.x86_64.rpm ...................................................................................................................................................................................[done (6.5 MiB/s)]
Retrieving package kubernetes1.23-kubeadm-1.23.0-3.2.x86_64                                                                                                                                                              (8/9),  10.6 MiB ( 54.3 MiB unpacked)
Retrieving: kubernetes1.23-kubeadm-1.23.0-3.2.x86_64.rpm ...................................................................................................................................................................................[done (9.2 MiB/s)]
Retrieving package cri-o-kubeadm-criconfig-1.22.0-1.5.x86_64                                                                                                                                                             (9/9),  78.0 KiB (  167   B unpacked)
Retrieving: cri-o-kubeadm-criconfig-1.22.0-1.5.x86_64.rpm ..............................................................................................................................................................................................[done]


Checking for file conflicts: ...........................................................................................................................................................................................................................[done]
(1/9) Installing: kubernetes1.23-apiserver-1.23.0-3.2.x86_64 ...........................................................................................................................................................................................[done]
(2/9) Installing: kubernetes1.23-client-1.23.0-3.2.x86_64 ..............................................................................................................................................................................................[done]
(3/9) Installing: kubernetes1.23-kubelet-1.23.0-3.2.x86_64 .............................................................................................................................................................................................[done]
(4/9) Installing: kubernetes1.23-proxy-1.23.0-3.2.x86_64 ...............................................................................................................................................................................................[done]
update-alternatives: using /usr/bin/kubectl1.23 to provide /usr/bin/kubectl (kubectl) in auto mode
(5/9) Installing: kubernetes1.23-client-common-1.23.0-3.2.x86_64 .......................................................................................................................................................................................[done]
Updating /etc/sysconfig/kubelet ...
(6/9) Installing: kubernetes1.23-kubelet-common-1.23.0-3.2.x86_64 ......................................................................................................................................................................................[done]
(7/9) Installing: kubernetes1.22-kubelet-1.22.4-2.4.x86_64 .............................................................................................................................................................................................[done]
(8/9) Installing: kubernetes1.23-kubeadm-1.23.0-3.2.x86_64 .............................................................................................................................................................................................[done]
Updating /etc/sysconfig/kubelet ...
(9/9) Installing: cri-o-kubeadm-criconfig-1.22.0-1.5.x86_64 ............................................................................................................................................................................................[done]

[/noparse]


 root  ~  zypper se -si '/^kube/'
Loading repository data...
Reading installed packages...


S  | Name                          | Type    | Version     | Arch   | Repository
---+-------------------------------+---------+-------------+--------+----------------------
i+ | kubernetes-apiserver          | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-apiserver          | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-client             | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-client             | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-coredns            | package | 1.8.6-22.3  | x86_64 | Main Repository (OSS)
i+ | kubernetes-coredns            | package | 1.8.6-22.3  | x86_64 | openSUSE-20220310-0
i+ | kubernetes-etcd               | package | 3.5.1-22.3  | x86_64 | Main Repository (OSS)
i+ | kubernetes-etcd               | package | 3.5.1-22.3  | x86_64 | openSUSE-20220310-0
i+ | kubernetes-kubeadm            | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-kubeadm            | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-kubelet            | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-kubelet            | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-proxy              | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-proxy              | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i  | kubernetes1.22-kubelet        | package | 1.22.4-2.4  | x86_64 | Main Repository (OSS)
i  | kubernetes1.22-kubelet        | package | 1.22.4-2.4  | x86_64 | openSUSE-20220310-0
i  | kubernetes1.23-apiserver      | package | 1.23.0-3.2  | x86_64 | Main Repository (OSS)
i  | kubernetes1.23-apiserver      | package | 1.23.0-3.2  | x86_64 | openSUSE-20220310-0
i  | kubernetes1.23-client         | package | 1.23.0-3.2  | x86_64 | Main Repository (OSS)
i  | kubernetes1.23-client         | package | 1.23.0-3.2  | x86_64 | openSUSE-20220310-0
i  | kubernetes1.23-client-common  | package | 1.23.0-3.2  | x86_64 | Main Repository (OSS)
i  | kubernetes1.23-client-common  | package | 1.23.0-3.2  | x86_64 | openSUSE-20220310-0
i  | kubernetes1.23-kubeadm        | package | 1.23.0-3.2  | x86_64 | Main Repository (OSS)
i  | kubernetes1.23-kubeadm        | package | 1.23.0-3.2  | x86_64 | openSUSE-20220310-0
i  | kubernetes1.23-kubelet        | package | 1.23.0-3.2  | x86_64 | Main Repository (OSS)
i  | kubernetes1.23-kubelet        | package | 1.23.0-3.2  | x86_64 | openSUSE-20220310-0
i  | kubernetes1.23-kubelet-common | package | 1.23.0-3.2  | x86_64 | Main Repository (OSS)
i  | kubernetes1.23-kubelet-common | package | 1.23.0-3.2  | x86_64 | openSUSE-20220310-0
i  | kubernetes1.23-proxy          | package | 1.23.0-3.2  | x86_64 | Main Repository (OSS)
i  | kubernetes1.23-proxy          | package | 1.23.0-3.2  | x86_64 | openSUSE-20220310-0

[/noparse]

and when I try to unistall them


 root  ~  zypper remove 'kube*'                                                                                                                                                                                                                       104
Reading installed packages...
Resolving package dependencies...


The following 16 packages are going to be REMOVED:
  cri-o-kubeadm-criconfig kubernetes-apiserver kubernetes-client kubernetes-coredns kubernetes-etcd kubernetes-kubeadm kubernetes-kubelet kubernetes-proxy kubernetes1.22-kubelet kubernetes1.23-apiserver kubernetes1.23-client kubernetes1.23-client-common
  kubernetes1.23-kubeadm kubernetes1.23-kubelet kubernetes1.23-kubelet-common kubernetes1.23-proxy


16 packages to remove.
After the operation, 624.0 MiB will be freed.
Continue? [y/n/v/...? shows all options] (y): y
error: package kubernetes-apiserver-1.23.0-22.3.x86_64 is not installed
( 1/16) Removing kubernetes-apiserver-1.23.0-22.3.x86_64 ..............................................................................................................................................................................................[error]
Removal of (216)kubernetes-apiserver-1.23.0-22.3.x86_64(@System) failed:
Error: Subprocess failed. Error: RPM failed: Command exited with status 1.
Abort, retry, ignore? [a/r/i] (a): i
error: package kubernetes-client-1.23.0-22.3.x86_64 is not installed
( 2/16) Removing kubernetes-client-1.23.0-22.3.x86_64 .................................................................................................................................................................................................[error]
Removal of (217)kubernetes-client-1.23.0-22.3.x86_64(@System) failed:
Error: Subprocess failed. Error: RPM failed: Command exited with status 1.
Abort, retry, ignore? [a/r/i] (a): i
error: package kubernetes-coredns-1.8.6-22.3.x86_64 is not installed
( 3/16) Removing kubernetes-coredns-1.8.6-22.3.x86_64 .................................................................................................................................................................................................[error]
Removal of (218)kubernetes-coredns-1.8.6-22.3.x86_64(@System) failed:
Error: Subprocess failed. Error: RPM failed: Command exited with status 1.
Abort, retry, ignore? [a/r/i] (a): i
error: package kubernetes-etcd-3.5.1-22.3.x86_64 is not installed
( 4/16) Removing kubernetes-etcd-3.5.1-22.3.x86_64 ....................................................................................................................................................................................................[error]
Removal of (219)kubernetes-etcd-3.5.1-22.3.x86_64(@System) failed:
Error: Subprocess failed. Error: RPM failed: Command exited with status 1.
Abort, retry, ignore? [a/r/i] (a): i
error: package kubernetes-kubeadm-1.23.0-22.3.x86_64 is not installed
( 5/16) Removing kubernetes-kubeadm-1.23.0-22.3.x86_64 ................................................................................................................................................................................................[error]
Removal of (220)kubernetes-kubeadm-1.23.0-22.3.x86_64(@System) failed:
Error: Subprocess failed. Error: RPM failed: Command exited with status 1.
Abort, retry, ignore? [a/r/i] (a): i
error: package kubernetes-kubelet-1.23.0-22.3.x86_64 is not installed
( 6/16) Removing kubernetes-kubelet-1.23.0-22.3.x86_64 ................................................................................................................................................................................................[error]
Removal of (221)kubernetes-kubelet-1.23.0-22.3.x86_64(@System) failed:
Error: Subprocess failed. Error: RPM failed: Command exited with status 1.
Abort, retry, ignore? [a/r/i] (a): i
error: package kubernetes-proxy-1.23.0-22.3.x86_64 is not installed
( 7/16) Removing kubernetes-proxy-1.23.0-22.3.x86_64 ..................................................................................................................................................................................................[error]
Removal of (222)kubernetes-proxy-1.23.0-22.3.x86_64(@System) failed:
Error: Subprocess failed. Error: RPM failed: Command exited with status 1.
Abort, retry, ignore? [a/r/i] (a): i
( 8/16) Removing kubernetes1.23-apiserver-1.23.0-3.2.x86_64 ............................................................................................................................................................................................[done]
( 9/16) Removing kubernetes1.23-client-1.23.0-3.2.x86_64 ...............................................................................................................................................................................................[done]
(10/16) Removing kubernetes1.23-kubeadm-1.23.0-3.2.x86_64 ..............................................................................................................................................................................................[done]
(11/16) Removing kubernetes1.23-proxy-1.23.0-3.2.x86_64 ................................................................................................................................................................................................[done]
update-alternatives: warning: alternative /usr/bin/kubectl1.23 (part of link group kubectl) doesn't exist; removing from list of alternatives
(12/16) Removing kubernetes1.23-client-common-1.23.0-3.2.x86_64 ........................................................................................................................................................................................[done]
(13/16) Removing cri-o-kubeadm-criconfig-1.22.0-1.5.x86_64 .............................................................................................................................................................................................[done]
(14/16) Removing kubernetes1.22-kubelet-1.22.4-2.4.x86_64 ..............................................................................................................................................................................................[done]
(15/16) Removing kubernetes1.23-kubelet-1.23.0-3.2.x86_64 ..............................................................................................................................................................................................[done]
(16/16) Removing kubernetes1.23-kubelet-common-1.23.0-3.2.x86_64 .....<5%>=================================================================================================================================================================================/](16/16) Removing kubernetes1.23-kubelet-common-1.23.0-3.2.x86_64 .......................................................................................................................................................................................[done]
There are running programs which still use files and libraries deleted or updated by recent upgrades. They should be restarted to benefit from the latest updates. Run 'zypper ps -s' to list these programs.

[/noparse]

So I end up with this again


 root  ~  zypper se -si '/^kube/'
Loading repository data...
Reading installed packages...


S  | Name                 | Type    | Version     | Arch   | Repository
---+----------------------+---------+-------------+--------+----------------------
i+ | kubernetes-apiserver | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-apiserver | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-client    | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-client    | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-coredns   | package | 1.8.6-22.3  | x86_64 | Main Repository (OSS)
i+ | kubernetes-coredns   | package | 1.8.6-22.3  | x86_64 | openSUSE-20220310-0
i+ | kubernetes-etcd      | package | 3.5.1-22.3  | x86_64 | Main Repository (OSS)
i+ | kubernetes-etcd      | package | 3.5.1-22.3  | x86_64 | openSUSE-20220310-0
i+ | kubernetes-kubeadm   | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-kubeadm   | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-kubelet   | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-kubelet   | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0
i+ | kubernetes-proxy     | package | 1.23.0-22.3 | x86_64 | Main Repository (OSS)
i+ | kubernetes-proxy     | package | 1.23.0-22.3 | x86_64 | openSUSE-20220310-0

[/noparse]

As you see manyfold in your listings, all of those packages are mentioned twice, everytime for two dfferent repositories. Thus it seems that your list of repositories is not as it should be. So please post

zypper lr -dU

for inspection.

You ignored this.

Somehow it attempts to remove packages with the wrong name - it has extra “(216)” at the beginning. It is unclear whether this is zypper or RPM issue. As you ignored my request, we still do not know what RPM believes is installed.