Bug 1733170 - [rhel8] nfs-utils warning when package removed: file /var/lib/nfs/statd: remove failed: No such file or directory
Summary: [rhel8] nfs-utils warning when package removed: file /var/lib/nfs/statd: remo...
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: nfs-utils
Version: 8.0
Hardware: All
OS: Linux
Target Milestone: rc
: 8.4
Assignee: Alice Mitchell
QA Contact: Yongcheng Yang
Depends On: 1377649
TreeView+ depends on / blocked
Reported: 2019-07-25 10:15 UTC by Yongcheng Yang
Modified: 2020-12-01 12:02 UTC (History)
5 users (show)

Fixed In Version: nfs-utils-2.3.3-36.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1377649
Last Closed:
Type: Bug
Target Upstream Version:

Attachments (Terms of Use)
Patch to cleanup the warnings (882 bytes, patch)
2020-10-12 13:38 UTC, Alice Mitchell
no flags Details | Diff

Comment 3 Troy Dawson 2020-03-13 15:33:52 UTC
I'm so sorry for not getting to this before.
It must have came in the middle of a bunch of other bugzilla's and I just went by it without looking.

The problem is with the %preun section of the spec file.
In there you are doing
    rm -rf /var/lib/nfs/statd
    rm -rf /var/lib/nfs/v4recovery

And yet in your %files section you have

%dir %{_sharedstatedir}/nfs/v4recovery
%dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd
%dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd/sm
%dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd/sm.bak

So, when it get's to the files section, it gives a non-fatal error.  It's trying to remove files that you have already removed manually.
My suggestion, don't remove files in %preun.  If you need to, don't do such a wide deletion.  Maybe something like
    rm -rf /var/lib/nfs/v4recovery/*

The last line
warning: directory /var/lib/nfs/rpc_pipefs: remove failed: Device or resource busy

Sounds like some service was not turned off before uninstalling.
Looking at the %preun script, I believe it is sortof right in the spec file, but there must be a bug in the %systemd_preun macro.
This is what actually is in the %preun script.
# rpm -q --scripts nfs-utils
if [ $1 -eq 0 ] ; then 
        # Package removal, not upgrade 
        systemctl --no-reload disable nfs-server.server > /dev/null 2>&1 || : 
        systemctl stop nfs-server.server > /dev/null 2>&1 || : 

That is trying to stop nfs-server.server not nfs-server.service
If you try doing the script by hand you get

# systemctl stop nfs-server.server
Failed to stop nfs-server.server.service: Unit nfs-server.server.service not loaded.
# systemctl status nfs-server.server
Unit nfs-server.server.service could not be found.

But if you switch it to nfs-server.service you get
# systemctl stop nfs-server.service
# systemctl status nfs-server.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

I hope this helps.

Comment 8 Alice Mitchell 2020-08-17 16:44:55 UTC
As I assume the intention here is to ensure this directory and its contents are always removed, either the %preun commands should be modified to empty the directory whilst leaving the actually directory there for %files to clean up, or simply move the cleanup to %postun

Comment 12 Alice Mitchell 2020-10-12 13:38:12 UTC
Created attachment 1720966 [details]
Patch to cleanup the warnings

Moving the directory removal into %postun scriplet ensures that cleanup happens but doesnt trigger the warnings

Comment 14 Alice Mitchell 2020-10-15 16:21:08 UTC
I don't think it will cause an issue as both the %preun and %postun try to stop the same service, and it doesn't generate any errors or warnings that I can see. there is probably scope to clean that up however

Comment 15 Yongcheng Yang 2020-10-19 04:40:45 UTC
Thanks for the explanation.

I'm marking this as "Tested" and feel free to add it into 8.4.0 nfs-utils erratum.

Comment 18 Yongcheng Yang 2020-12-01 12:02:25 UTC
Moving to VERIFIED based on comment #14

[root@rhel-8-4-latest ~]# rpm -q nfs-utils
[root@rhel-8-4-latest ~]# rpm -e nfs-utils
warning: directory /var/lib/nfs/rpc_pipefs: remove failed: Device or resource busy
[root@rhel-8-4-latest ~]# rpm -q nfs-utils
package nfs-utils is not installed
[root@rhel-8-4-latest ~]#

Note You need to log in before you can comment on or make changes to this bug.