Bug 9982

Summary: nfs-utils is missing service related rpm scripts
Product: Mageia Reporter: Anssi Hannula <anssi.hannula>
Component: RPM PackagesAssignee: Guillaume Rousse <guillomovitch>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Normal CC: luigiwalser, mageia, tmb
Version: 3   
Target Milestone: ---   
Hardware: i586   
OS: Linux   
Whiteboard:
Source RPM: nfs-utils CVE:
Status comment:

Description Anssi Hannula 2013-05-04 22:49:56 CEST
r259832 ( http://svnweb.mageia.org/packages/cauldron/nfs-utils/current/SPECS/nfs-utils.spec?r1=252212&r2=259832 ) removed the %_post_service and %_preun_service service calls altogether and didn't add anything to replace them.

As a result, all the nfs services are disabled on upgrade and on new installations, and are not restarted on any future package updates as they should be.

Since the nfs-utils unit stuff was copied from fedora, I suggest that the rpm script logic is copied as well (not directly, since their legacy script structure and rpm macros differ from ours).

Like follows (untested):

%post
%_post_unit nfs-lock.service nfs-idmap.service

if [ $1 -eq 2 ]; then
	# Package upgrade, restart services but do not enable by default
	%_post_unit nfs-secure.service nfs-secure-server.service nfs-server.service nfs-blkmap.service
fi

%preun
%_preun_unit nfs-lock.service nfs-secure.service nfs-secure-server.service nfs-server.service nfs-blkmap.service nfs-idmap.service

%triggerun -- nfs-utils < 1:1.2.6-2
# Upgrade from sysv init scripts
if /sbin/chkconfig --level 3 nfs-common ; then
	/bin/systemctl enable nfs-lock.service nfs-idmap.service >/dev/null 2>&1 || :
fi
if /sbin/chkconfig --level 3 nfs-server ; then
	/bin/systemctl enable nfs-server.service >/dev/null 2>&1 || :
fi


CC'd Colin to double-check.

I can test+commit if I have your OK.

I have to say I really preferred the previous style, with common + server initscripts only and components enabled/disabled via /etc/sysconfig/nfs*, but I suppose I'm ok with this as well as long as this bug is fixed.
Comment 1 Anssi Hannula 2013-05-04 23:02:18 CEST
I have to say I don't completely grasp the intended relationships between e.g. nfs.target and nfs-server.service. Can either of you explain it? (if not, I'll just dig deeper)

Of course the actual needed scripts in the rpm depend a bit on that...
Comment 2 David Walser 2013-05-05 18:43:45 CEST
I'm not sure it's as simple as running some scriplets, as running systemctl daemon-reload still does not make systemd see these units.  I looked on an up-to-date Cauldron VM, and this affects some other services too.  Running drakxservices in a terminal gives this output:
Failed to issue method call: Unit atd.service is not loaded.
Failed to issue method call: Unit avahi-daemon.service is not loaded.
Failed to issue method call: Unit avahi-dnsconfd.service is not loaded.
Failed to issue method call: Unit httpd.service is not loaded.
Failed to issue method call: Unit nfs-blkmap.service is not loaded.
Failed to issue method call: Unit nfs-lock.service is not loaded.
Failed to issue method call: Unit nfs-secure.service is not loaded.
Failed to issue method call: Unit nfs-secure-server.service is not loaded.
Failed to issue method call: Unit nfs-server.service is not loaded.
Failed to issue method call: Unit rpcbind.service is not loaded.
Failed to issue method call: Unit rtkit-daemon.service is not loaded.
Failed to issue method call: Unit shorewall.service is not loaded.
Failed to issue method call: Unit udisksd.service is not loaded.
Failed to issue method call: Unit xinetd.service is not loaded.

Why are those services not loaded!?  None of them show up in systemctl --all, but luckily drakxservices still shows them in the GUI at least.

CC: (none) => luigiwalser

Comment 3 Colin Guthrie 2013-05-05 19:18:22 CEST
@David: If the units are not enabled then there is often no reason to load the unit. systemctl --all will not necessarily show all units on disk, it just shows the ones systemd is tracking (which might include some inactive units but depending on garbage collection, it might not). To show all the unit files on disk, "systemctl list-unit-files" should be used. drakxservices uses this call itself to get a full list of all units.

I'll comment on the wider issue shortly.
Comment 4 David Walser 2013-05-05 19:27:22 CEST
(In reply to Colin Guthrie from comment #3)
> @David: If the units are not enabled then there is often no reason to load
> the unit. systemctl --all will not necessarily show all units on disk, it
> just shows the ones systemd is tracking (which might include some inactive
> units but depending on garbage collection, it might not). To show all the
> unit files on disk, "systemctl list-unit-files" should be used.
> drakxservices uses this call itself to get a full list of all units.

When did this change happen?  Can it be fixed?  This is really bad.

Please don't say this behavior is OK.  It conflicts with all of the documentation I have read on systemd over the last couple of years, it's confusing, it's unintuitive, and it's just plain silly.
Comment 5 Colin Guthrie 2013-05-05 19:42:07 CEST
@David, this is not a change, it's always been like that. This is why drakxservices was written to use list-unit-files. Nothing has changed here. But it's off topic, so lets discuss it elsewhere if possible?
Comment 6 Colin Guthrie 2013-05-05 19:42:30 CEST
OK, so looking at things, it seesm the following services only start when nfs.target is started:
 nfs-idmap.service
 nfs-rquotad.service 
 nfs-mountd.service 

Forgive my ignorance but I thought idmap was needed on client machines? If nfs.target is "Network File System Server" then I can't help but feel that idmap should NOT be part of nfs.target.

I know these come from Fedora, but it just doesn't seem to make sense to me.

I'd have something like the following.

At the top level:
nfs-client.target
nfs-server.target

Each of the components should have install sections referring to one of these targets. That way enabling or disabling either of the targets will be approximately the same as enabling or disabling nfs-common and nfs-server in the past. In fact, perhaps nfs-client.target should just be called nfs-common.target?

We should also try and push this change to fedora (and anyone else using those units) and eventually upstream.

But as things stand the nfs.target seems wrong.
Comment 7 Colin Guthrie 2013-05-05 23:54:25 CEST
Hmm, OK, so it seems:
nfs-server.service:Requires=nfs-idmap.service nfs-mountd.service nfs-rquotad.service

So these services should be started by the single nfs-server.service. That's good and sensible I think.

Sadly nfs-rquotad.service is somewhat useless as we apparently don't actually ship a /usr/sbin/rpc.rquotad. Looks like there is a missing require on the quota package which contains the binary. Very odd to have the units split up such that unit was in one package and binary in another... better to call the unit rpc-rstatd.service and ship it instead in the quota package.
Comment 8 Guillaume Rousse 2013-05-06 21:33:51 CEST
idmap (idmapd, actually) is indeed needed both sides. The only server/client specific daemons are svcgssd/gssd, but only for secure (kerberos, mainly) NFS, and they are already managed by distinct services (nfs-secure-server, nfs-secure). I agree having distinct top-level targets for client and server case would be clearer:
nfs-client.target
nfs-server.target
nfs-secure-client.unit
nfs-secure-server.unit

Regarding the missing quota binary, Fedora solves it with a dependency on quota package in its nfs-utils package.
Comment 9 Colin Guthrie 2013-05-06 22:18:12 CEST
OK, I've done tidyups.

They seems to work for me on a server and a client.

nfs.target is basically the same as the old nfs-common under sysvinit. If you enable nfs-server.service it will be wanted by nfs.target so this still needs to be enabled also. I was going to use Also= in the units but it seems there may be a slight bug/thinko about the handling of this when disabling units that makes it a bad idea.

I tried to put code in that should migrate nicely from sysvinit...

A review of the changes would be nice :)
Comment 10 Colin Guthrie 2013-05-09 14:29:18 CEST
Anyone get a chance to test these changes? I'd like to push this if we're good for now. More dev/tidyup can happen in due course.
Comment 11 Thomas Backlund 2013-05-18 18:21:26 CEST
 nfs-utils-1.2.7-3.mga3 pushed to release

Status: NEW => RESOLVED
CC: (none) => tmb
Resolution: (none) => FIXED