Bug 1316369 - RPM enables nfs-client.target against default systemd-preset policy
RPM enables nfs-client.target against default systemd-preset policy
Status: NEW
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: nfs-utils (Show other bugs)
7.2
All Linux
medium Severity low
: rc
: ---
Assigned To: Steve Dickson
Yongcheng Yang
: EasyFix, Reopened, Reproducer
Depends On:
Blocks: 1298243 1385242
  Show dependency treegraph
 
Reported: 2016-03-10 01:00 EST by Aaron Howell
Modified: 2017-03-30 13:33 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-01-17 10:06:38 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Aaron Howell 2016-03-10 01:00:23 EST
Description of problem:
I believe Bug 1245804 was handled incorrectly. The systemd-preset should have been updated to indicate this service is enabled by default. Then this RPM only needs to run "systemctl preset nfs-client.target" as it previously was to enable or disable the service according to systemd-preset policy.

Version-Release number of selected component (if applicable):
nfs-utils-1.3.0-0.21.el7_2.x86_64
redhat-release-server-7.2-9.el7.x86_64

How reproducible:
Everytime

Steps to Reproduce:
1. sudo systemctl status nfs-client.target 

Actual results:
● nfs-client.target - NFS client services
   Loaded: loaded (/usr/lib/systemd/system/nfs-client.target; enabled; vendor preset: disabled)
   Active: active since Thu 2016-03-10 16:53:45 AEDT; 3s ago

Expected results:
● nfs-client.target - NFS client services
   Loaded: loaded (/usr/lib/systemd/system/nfs-client.target; enabled; vendor preset: enabled)
   Active: active since Thu 2016-03-10 16:53:45 AEDT; 3s ago

-----OR-----

● nfs-client.target - NFS client services
   Loaded: loaded (/usr/lib/systemd/system/nfs-client.target; disabled; vendor preset: disabled)
   Active: active since Thu 2016-03-10 16:53:45 AEDT; 3s ago

Additional info:
/usr/lib/systemd/system-preset/90-default.preset
Comment 2 Steve Dickson 2016-03-24 14:20:18 EDT
(In reply to Aaron Howell from comment #0)
> Description of problem:
> I believe Bug 1245804 was handled incorrectly. The systemd-preset should
> have been updated to indicate this service is enabled by default. Then this
> RPM only needs to run "systemctl preset nfs-client.target" as it previously
> was to enable or disable the serviceaccording to systemd-preset policy.
> 
But systemd-preset didn't enable *anything* even when the service 
or target which is the reason I explicitly enabled the 
target/services. 

Another thing was it is literally impossible to debug why systemd-preset
was not working so I just went for the for sure thing
Comment 3 Aaron Howell 2016-04-04 00:09:39 EDT
(In reply to Steve Dickson from comment #2)
> (In reply to Aaron Howell from comment #0)
> > Description of problem:
> > I believe Bug 1245804 was handled incorrectly. The systemd-preset should
> > have been updated to indicate this service is enabled by default. Then this
> > RPM only needs to run "systemctl preset nfs-client.target" as it previously
> > was to enable or disable the serviceaccording to systemd-preset policy.
> > 
> But systemd-preset didn't enable *anything* even when the service 
> or target which is the reason I explicitly enabled the 
> target/services. 
> 
> Another thing was it is literally impossible to debug why systemd-preset
> was not working so I just went for the for sure thing

While you have stated you looked into doing it the correct way, I'm sorry to say but something must have been missed. It is literally as simple as running the following as root:
$ systemctl status nfs-client.target
● nfs-client.target - NFS client services
   Loaded: loaded (/usr/lib/systemd/system/nfs-client.target; disabled; vendor preset: disabled)
   Active: inactive (dead)
$ echo "enable nfs-client.target" >> /etc/systemd/system-preset/01-policy.preset 
enable nfs-client.target
$ systemctl daemon-reload
$ systemctl status nfs-client.target
● nfs-client.target - NFS client services
   Loaded: loaded (/usr/lib/systemd/system/nfs-client.target; disabled; vendor preset: enabled)
   Active: inactive (dead)
$ systemctl preset nfs-client.target
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-client.target to /usr/lib/systemd/system/nfs-client.target.
Created symlink from /etc/systemd/system/remote-fs.target.wants/nfs-client.target to /usr/lib/systemd/system/nfs-client.target.
$ systemctl status nfs-client.target
● nfs-client.target - NFS client services
   Loaded: loaded (/usr/lib/systemd/system/nfs-client.target; enabled; vendor preset: enabled)
   Active: inactive (dead)

However, rather than using a policy file in the /etc area as I have done, I would encourage Redhat to update it in the correct location for default Redhat policy:
/usr/lib/systemd/system-preset/90-default.preset
Comment 4 Steve Dickson 2016-04-05 12:46:44 EDT
Here is the diff in question

@@ -299,7 +298,12 @@ else
 fi
 
 %post
-%systemd_post nfs-client.target
+echo "post 1=$1"
+if [ $1 -eq 1 ] ; then
+       # Initial installation
+       /bin/systemctl enable nfs-client.target >/dev/null 2>&1 || :
+       /bin/systemctl restart nfs-config  >/dev/null 2>&1 || :
+fi
 %systemd_post nfs-config
 %systemd_post nfs-server
 
@@ -337,6 +341,13 @@ fi
 /bin/systemctl stop rpc-svcgssd  >/dev/null 2>&1 || :
 /bin/systemctl enable nfs-client.target  >/dev/null 2>&1 || :
 
+%triggerin -- nfs-utils > 1:1.3.0-0.1
+# reset configuration files and running daemons
+if [ $1 -eq 2 ] ; then
+       /bin/systemctl enable nfs-client.target >/dev/null 2>&1 || :
+       /bin/systemctl restart nfs-config  >/dev/null 2>&1 || :
+fi
+

What was missing?
Comment 5 Aaron Howell 2016-04-05 19:07:13 EDT
(In reply to Steve Dickson from comment #4)
> What was missing?

Mostly the missing entry in /usr/lib/systemd/system-preset/90-default.preset so that preset policy matches expectations. And when a "systemctl preset-all" is run it doesn't disable nfs-client.target unexpectedly.

However I would say that previous change is opposite to recommendations and requirements (rpms should not explicitly enable/disable services - should rely on systemd-preset policy), therefore after placing in the policy the rpm lines:
/bin/systemctl enable nfs-client.target
should be changed to 
/bin/systemctl preset nfs-client.target

Cheers
Aaron
Comment 6 Steve Dickson 2016-05-19 15:16:25 EDT
(In reply to Aaron Howell from comment #5)
> (In reply to Steve Dickson from comment #4)
> > What was missing?
> 
> Mostly the missing entry in /usr/lib/systemd/system-preset/90-default.preset
> so that preset policy matches expectations. And when a "systemctl
> preset-all" is run it doesn't disable nfs-client.target unexpectedly.
But it does not enable nfs-client.target either since there is
no "enable nfs-client.target" line, correct? 

I don't own the redhat-release-server-7.3 package, so how do I
get something in there?

> 
> However I would say that previous change is opposite to recommendations and
> requirements (rpms should not explicitly enable/disable services - should
> rely on systemd-preset policy), therefore after placing in the policy the
> rpm lines:
> /bin/systemctl enable nfs-client.target
> should be changed to 
> /bin/systemctl preset nfs-client.target
Once the above question is answered.... I'll make this change.
Comment 7 Aaron Howell 2016-06-13 22:16:48 EDT
Sorry I am a little confused.

Isn't nfs-utils and a redhat-release-server both Redhat packages? And aren't you Redhat employee? Isn't there a process for changes to multiple packages?
Comment 8 Yu Watanabe 2016-08-07 22:26:45 EDT
If nfs-client.target is enabled by default, I think we need to create an entry like the following links:

https://bugzilla.redhat.com/show_bug.cgi?id=855372
https://bugzilla.redhat.com/show_bug.cgi?id=876237
Comment 9 Yu Watanabe 2016-08-07 22:39:35 EDT
Please see also
https://fedoraproject.org/wiki/Packaging:DefaultServices
Comment 13 Red Hat Bugzilla Rules Engine 2017-01-17 10:06:38 EST
Development Management has reviewed and declined this request. You may appeal this decision by reopening this request.
Comment 14 Aaron Howell 2017-01-17 14:40:08 EST
As there is no information about the decision - just the outcome. I cannot make any comments about the undiscussed decision. However I can see no logical path to the outcome - what possible reason could you have not to match the OS systemd policy to the reality of the OS?

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