Bug 1220592

Summary: Installation of virtiofsd-1.10.1-3.1.x86_64 fails on TW snapshot 2024227
Product: [openSUSE] openSUSE Tumbleweed Reporter: Nik Kai <nik.kaiser87>
Component: Virtualization:OtherAssignee: Caleb Crane <caleb.crane>
Status: REOPENED --- QA Contact: E-mail List <qa-bugs>
Severity: Minor    
Priority: P3 - Medium CC: 0u103mgv, aschnell, broetlybahn, canalcheferaser, code, felix.niederwanger, i, ioannis.bonatakis, jechojekov, jfehlig, lcatinaud, martin.wilck, mcepl, mrueckert, oliver, olivier.tilloy, pdostal, pestaa, rokejulianlockhart+1674683091, santiago.zarate, scott.beamer, sebix+novell.com, shundhammer, steven.kowalik, tadeus856, virex
Version: CurrentFlags: caleb.crane: needinfo?
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE Tumbleweed   
See Also: https://bugzilla.opensuse.org/show_bug.cgi?id=1221119
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Terminal error that shows up while trying distro-upgrade

Description Nik Kai 2024-02-28 23:15:09 UTC
After today's dup, the mentioned package fails to install.

(1/1) Install: virtiofsd-1.10.1-3.1.x86_64 .................................................[Error]
Installation of virtiofsd-1.10.1-3.1.x86_64 failed:
Error: Subprocess failed. Error: RPM failed: Command terminated with status 1.
Cancel, retry, ignore? [a/w/i] (a)

Not sure what to do here. I hope this is the right place to report the issue.
Thanks!
Comment 1 James Fehlig 2024-02-29 05:03:22 UTC
Yes, it's the correct place. Failure also noted here https://bugzilla.suse.com/show_bug.cgi?id=1220304#c2
Comment 2 Igor Kuznetsov 2024-02-29 05:30:58 UTC
Same bug.

I move the folder /usr/libexec/vitriofsd to temp folder and zypper installed this package fine.
Comment 3 David Disseldorp 2024-02-29 08:33:45 UTC
*** Bug 1220598 has been marked as a duplicate of this bug. ***
Comment 4 Benjamin Greiner 2024-02-29 10:17:08 UTC
The old rpm "can't replace a directory with a single file" deficiency.
Comment 5 Stefan Hundhammer 2024-02-29 12:12:02 UTC
Some more info here: bug #1220632
Comment 6 Benjamin Greiner 2024-02-29 12:24:24 UTC
*** Bug 1220304 has been marked as a duplicate of this bug. ***
Comment 7 Benjamin Greiner 2024-02-29 12:25:02 UTC
*** Bug 1220632 has been marked as a duplicate of this bug. ***
Comment 11 Jecho Jekov 2024-02-29 17:30:18 UTC
I ma running in the same issue as described in

https://bugzilla.suse.com/show_bug.cgi?id=1220598
https://bugzilla.suse.com/show_bug.cgi?id=1220632
https://bugzilla.suse.com/show_bug.cgi?id=1220592

The problem is that updating the package cannot be skipped if I deselect it in "Software Updates" popup in KDE. Even if I select a single unrelated package and deselect all others the process tries to update `virtiofsd` and fails.

This issue has been already reported here:

https://bugzilla.suse.com/show_bug.cgi?id=1186908
> Bug 1186908 - Software Updates applet: All available packages were updated even if I select only 1 of them
Comment 12 Caleb Crane 2024-02-29 18:31:07 UTC
I believe the simplest workaround is to remove the virtiofsd package with 'zypper rm virtiofsd' and then install again with 'zypper in virtiofsd'. Removing the package and then doing a distro upgrade may also work (due to it being a qemu dependency). 'zypper in --force virtiofsd' does not work. This should all be safe since virtiofsd doesn't have any dependencies.
Comment 13 Nik Kai 2024-02-29 19:48:23 UTC
(In reply to Caleb Crane from comment #12)
> This should all be safe since virtiofsd doesn't have any dependencies.

That does not seem to be correct:

sudo zypper rm virtiofsd
Installierte Pakete werden gelesen...
Paketabhängigkeiten werden aufgelöst...

Die folgenden 8 Pakete werden GELÖSCHT:
  libguestfs libguestfs-appliance libguestfs-winsupport libguestfs-xfs perl-Sys-Guestfs qemu-tools virtiofsd vm-install

8 packages are connected to virtiofsd if you have installed the virtualization group in Yast. 
It was also my first impulse to simply uninstall, then reinstall, but stopped there since I'm not sure what exactly happens if I uninstall all the other 8packages with it.
Comment 14 Laurent Catinaud 2024-02-29 21:08:39 UTC
Bug confirmed. 

The problem seems to be that the newer package includes the /usr/libexec/virtiofsd file while the previous one installed /usr/libexec/virtiofsd/virtiofsd. So zypper won't replace a directory with a file. But I suspect that putting the file in this wrong path can also creat problems.

The best seems to ignore and keep the old version (virtiofsd-1.10.1-2.1) as I got problems with my virtio network bridge after trying to force the newer versions (remove 1-2.1 without deps check then install 1-3.1). Some qemu program might be looking for the virtiofsd file in its previous path.
Comment 15 Stefan Hundhammer 2024-02-29 21:46:04 UTC
(In reply to Caleb Crane from comment #12)
> I believe the simplest workaround is to remove the virtiofsd package with
> 'zypper rm virtiofsd' and then install again with 'zypper in virtiofsd'.

This wanted to uninstall a whole bunch of qemu packages when I tried it.

It's far easier to download the new package, delete that directory and its contents, and install the downloaded package manually with 'rpm -Uhv' as described here:

  https://bugzilla.suse.com/show_bug.cgi?id=1220632#c4

This minimizes the disruption.
Comment 16 Caleb Crane 2024-02-29 22:11:04 UTC
(In reply to Stefan Hundhammer from comment #15)
> It's far easier to download the new package, delete that directory and its
> contents, and install the downloaded package manually with 'rpm -Uhv' as
> described here:
> 
>   https://bugzilla.suse.com/show_bug.cgi?id=1220632#c4
> 
> This minimizes the disruption.

Okay, I guess my test scenarios were too contrived. Thanks for sharing this method.

A couple other things of note when fixing this manually:

 - Ending up with virtiofsd installed to '/usr/libexec/virtiofsd/virtiofsd' is flawed and should have never happened to begin with. This bug is the result of trying to undo that badness. The correct path is 'usr/libexec/virtiofsd' for TW.
 - Ensure the file '/usr/share/qemu/vhost-user/50-virtiofsd.json' points to the correct path for the virtiofsd binary. ('/usr/libexec/virtiofsd' is assumed)
 - Ensure the file '/etc/apparmor.d/usr.sbin.virtqemud' includes the correct path for virtiofsd ('/usr/libexec/virtiofsd' is assumed)

Given the above, things should be functional again.
Comment 17 Marcus Rückert 2024-02-29 22:19:12 UTC
%pre
if [ -d /usr/libexec/virtiofsd ] ; then
  rm -rf /usr/libexec/virtiofsd
fi
Comment 18 James Fehlig 2024-02-29 22:21:44 UTC
(In reply to Laurent Catinaud from comment #14)
> The best seems to ignore and keep the old version (virtiofsd-1.10.1-2.1) as
> I got problems with my virtio network bridge after trying to force the newer
> versions (remove 1-2.1 without deps check then install 1-3.1). Some qemu
> program might be looking for the virtiofsd file in its previous path.

If anything, programs will look for virtiofsd in /usr/libexec/. Moving it requires updating apparmor profiles, etc. No need to deviate from the rest of the world.
Comment 19 James Fehlig 2024-02-29 22:22:46 UTC
(In reply to Marcus Rückert from comment #17)
> %pre
> if [ -d /usr/libexec/virtiofsd ] ; then
>   rm -rf /usr/libexec/virtiofsd
> fi

+1 :-)
Comment 20 Sebastian Balanta 2024-03-01 01:42:09 UTC
Created attachment 873140 [details]
Terminal error that shows up while trying distro-upgrade
Comment 21 James Fehlig 2024-03-01 14:22:11 UTC
*** Bug 1220730 has been marked as a duplicate of this bug. ***
Comment 22 Jecho Jekov 2024-03-01 19:47:28 UTC
My solution to allow other packages to be updated is to set the `viriofsd` package to "Protected -- Do not modify" in the YaST Package Manager until this is resolved.
Comment 23 Nik Kai 2024-03-01 22:24:40 UTC
(In reply to Jecho Jekov from comment #22)
> My solution to allow other packages to be updated is to set the `viriofsd`
> package to "Protected -- Do not modify" in the YaST Package Manager until
> this is resolved.

Same. I don't want to force install via removing the old package because it may be that some programs might expect virtiofsd in its old location. Imo this needs to be resolved by the developer/maintainer side.
Comment 24 Michael Schliebner 2024-03-04 11:42:38 UTC
Comment on attachment 873140 [details]
Terminal error that shows up while trying distro-upgrade

error: unpacking of archive failed on file /usr/libexec/virtiofsd;65e39691: 
cpio: File from package already exists as a directory in system
error: virtiofsd-1.10.1-3.1.x86_64: install failed
error: virtiofsd-1.10.1-2.1.x86_64: erase skipped
( 18/361) Installing: virtiofsd-1.10.1-3.1.x86_64 .......................[error]
Installation of virtiofsd-1.10.1-3.1.x86_64 failed:
Error: Subprocess failed. Error: RPM failed: Command exited with status 1.
Comment 25 Michael Schliebner 2024-03-04 11:45:18 UTC
(In reply to Nik Kai from comment #23)
> (In reply to Jecho Jekov from comment #22)
> > My solution to allow other packages to be updated is to set the `viriofsd`
> > package to "Protected -- Do not modify" in the YaST Package Manager until
> > this is resolved.
> 
> Same. I don't want to force install via removing the old package because it
> may be that some programs might expect virtiofsd in its old location. Imo
> this needs to be resolved by the developer/maintainer side.

Same. ""Protected -- Do not modify" in the YaST Package Manager until
it may be resolved."
Comment 26 hui 2024-03-07 12:05:20 UTC
*** Bug 1221098 has been marked as a duplicate of this bug. ***
Comment 27 Benjamin Greiner 2024-03-07 14:23:12 UTC
This still pops up at numerous support channels. It's not fixed yet.

(In reply to Marcus Rückert from comment #17)
> %pre
> if [ -d /usr/libexec/virtiofsd ] ; then
>   rm -rf /usr/libexec/virtiofsd
> fi

Should have submitted this days ago:
https://build.opensuse.org/request/show/1155986
Comment 28 Michael Andres 2024-03-08 14:14:56 UTC
*** Bug 1221119 has been marked as a duplicate of this bug. ***
Comment 29 James Fehlig 2024-03-08 20:38:13 UTC
Benjamin's fix has been accepted in Factory. We can close this now.
Comment 30 Michael Andres 2024-03-14 11:42:15 UTC
*** Bug 1221322 has been marked as a duplicate of this bug. ***
Comment 31 Michael Schliebner 2024-03-14 18:31:22 UTC
(In reply to James Fehlig from comment #29)
> Benjamin's fix has been accepted in Factory. We can close this now.

virtioFSD has been changed to "update" and vendor "Factory" 4 TW some days ago.
Serveral zypper dups l8r no more loveltters from zypper about rc=1

works for me, thank you!!
Comment 32 Martin Wilck 2024-04-03 08:18:13 UTC
For me, the problem still occurs, apparently because I've set ZYPP_SINGLE_RPMTRANS=1. Before anyone asks, I know it's tech preview; I like the feature, and I have it enabled as sort of a "beta tester" to find issues with it, like I just did.

While I can work around this easily, ZYPP_SINGLE_RPMTRANS has been around for 3 years. Quite a few people are waiting eagerly for it to leave tech preview state, and even become the default, on openSUSE. We should stop pushing workarounds for issues like this that are only effective if this variable is not set.

I assume that replacing %pre with %pretrans in Ben's fix would do the trick.
Comment 33 Caleb Crane 2024-04-03 14:27:25 UTC
(In reply to Martin Wilck from comment #32)
> For me, the problem still occurs, apparently because I've set
> ZYPP_SINGLE_RPMTRANS=1. Before anyone asks, I know it's tech preview; I like
> the feature, and I have it enabled as sort of a "beta tester" to find issues
> with it, like I just did.
Do you have a set of preferred references for this feature? I personally don't keep up to date with experimental zypper features, but I'm willing to explore the merits of this feature.

> I assume that replacing %pre with %pretrans in Ben's fix would do the trick.
My observation has been that many packages are moving away from %pretrans to %pre so I'm a little wary of going that direction without more research.
Comment 34 Marcus Rückert 2024-04-03 15:51:43 UTC
as replied in the imagemagick bug with the same issue

- %pretrans is even more dangerous than the cleanup in %pre
- %pretrans does not support shell scripts it needs to be implemented in lua

in general the recommendation is do _not_ replace directories with file/symlink or vice versa.
Comment 35 Martin Wilck 2024-04-08 17:11:54 UTC
(In reply to Caleb Crane from comment #33)

> Do you have a set of preferred references for this feature? I personally
> don't keep up to date with experimental zypper features, but I'm willing to
> explore the merits of this feature.

I don't remember everything off the top of my head. I recall that the upgrade is supposed to be faster, because rpm doesn't have to be called for every package in turn, and because %pretrans and and %posttrans scripts really only run once; this is a huge improvement e.g. for packages that require rebuilding the initrd. If you have 10 packages that want to rebuild the initrd in the transaction, you will rebuild it 10x with the traditional method, which causes time-consuming pointless work for the CPU.

Also, rpm itself is aware of the entire transaction, which simplifies matters and allows some additional optimizations, IIRC. I've seen this feature mentioned as possible solution to some problems in various bugs, but I don't recall them all.

Michael should be able to fill in more detail, also about the question why this has still not left tech preview state.
Comment 36 Martin Wilck 2024-04-08 17:19:27 UTC
(In reply to Marcus Rückert from comment #34)
> as replied in the imagemagick bug with the same issue
> 
> - %pretrans is even more dangerous than the cleanup in %pre
> - %pretrans does not support shell scripts it needs to be implemented in lua

You just said "its kinda dangerous", without providing much background. I can see that %pretrans might be tricky in particular for initial installation, when there's basically nothing we can rely on, but this is just a vague perception.
Adding some LUA code to unlink a file under /etc/alternatives might actually be possible.

> in general the recommendation is do _not_ replace directories with file/symlink or vice versa.

Yes. But obviously, this recommendation hasn't been followed well lately, and QA hasn't found the issues that this caused. The way this has played out, I have little confidence that such errors will be effectively avoided in the future.

Am I understanding correctly that you're basically saying "there will never be a fix for current and future directory <-> file replacement bugs that work with ZYPP_SINGLE_RPMTRANS=1"? Does this mean this feature is officially dead?
Comment 37 Marcus Rückert 2024-04-09 09:30:55 UTC
well there is a simple way to find that during the build by comparing the old build (which is available) with the new build and if we find a type collusion then always hard fail the build.
Comment 38 Martin Wilck 2024-04-09 10:16:13 UTC
so that would require a new rpmlint or post-build-check test to be implemented?
Comment 39 Marcus Rückert 2024-04-09 11:41:44 UTC
yes
Comment 40 Martin Wilck 2024-04-09 13:08:13 UTC
I guess if, as you say, the previous package is available on OBS, it would be sufficient to try install it and attempt an update.
Comment 41 Marcus Rückert 2024-04-16 11:21:27 UTC
related blog post about this and the dangers that come with it https://nordisch.org/posts/the-short-answer-is-dont/
Comment 42 Marcus Rückert 2024-04-16 12:01:39 UTC
the blog post has a bug and is being reworked.