Bug 2217057

Summary: %postun script's logic seems flawed
Product: [Fedora] Fedora Reporter: Tim Landscheidt <tim>
Component: zfs-fuseAssignee: Gwyn Ciesla <gwync>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 37CC: gwync
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: zfs-fuse-0.7.2.2-28.fc38 zfs-fuse-0.7.2.2-28.fc37 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-06-28 01:15:47 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:

Description Tim Landscheidt 2023-06-23 17:04:23 UTC
On update, zfs-fuse-0.7.2.2-27.fc37.x86_64 emitted:

| […]
|   Ausgeführtes Scriptlet: zfs-fuse-0.7.2.2-23.fc37.x86_64                                                                                                                              5/5 
| Removing files since we removed the last package
| […]

This felt odd as the package zfs-fuse definitely remained on the system.

The relevant %postun section reads:

| %postun
| %systemd_postun_with_restart zfs-fuse.service 
| echo "Removing files since we removed the last package"
| rm -rf /var/run/zfs
| rm -rf /var/lock/zfs

This seems to be the result of a logic error introduced by commit 1c50d5e79b9266a45f91d70eacec10fb745529f1; prior to that, %postun read:

| if [ $1 -ge 1 ] ; then
|     echo "Restarting since we have updated the package"
|     /sbin/service %{name} condrestart >/dev/null 2>&1 || :
| else
|     echo "Removing files since we removed the last package"
|     rm -rf /var/run/zfs
|     rm -rf /var/lock/zfs
| fi

This was changed to:

| /bin/systemctl daemon-reload >/dev/null 2>&1 || :
| if [ $1 -ge 1 ] ; then
|     # Package upgrade, not uninstall
|     /bin/systemctl try-restart zfs-fuse.service >/dev/null 2>&1 || :
|     echo "Removing files since we removed the last package"
|     rm -rf /var/run/zfs
|     rm -rf /var/lock/zfs
| fi

I. e., the "else" line was omitted.  AFAICT, this is not the intended behaviour.

Reproducible: Didn't try

Comment 1 Gwyn Ciesla 2023-06-26 16:48:19 UTC
Ah, yes, and then it changed to %systemd_postun_with_restart, which includes the -ge logic but no else. I'll add an -lt stanza to address this. Good catch, thank you!

Comment 2 Fedora Update System 2023-06-26 17:34:29 UTC
FEDORA-2023-e1cf11093f has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-e1cf11093f

Comment 3 Fedora Update System 2023-06-27 10:45:19 UTC
FEDORA-2023-e1cf11093f has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-e1cf11093f`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-e1cf11093f

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 4 Fedora Update System 2023-06-27 10:55:37 UTC
FEDORA-2023-00ef1c59f6 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-00ef1c59f6`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-00ef1c59f6

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Fedora Update System 2023-06-28 01:15:47 UTC
FEDORA-2023-00ef1c59f6 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 6 Fedora Update System 2023-07-05 01:19:11 UTC
FEDORA-2023-e1cf11093f has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.