FS#30226 - [openntpd] systemd unit should depend on systemd-timedated-ntp.target

Attached to Project: Community Packages
Opened by Rodrigo Rivas Costa (rodrigorc) - Saturday, 09 June 2012, 22:17 GMT
Last edited by Dave Reisner (falconindy) - Monday, 20 August 2012, 18:01 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Tom Gundersen (tomegun)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

Currently, openntpd (and maybe other NTP clients) ship with a openntpd.service file to be used with systemd.

It contains:

[Install]
WantedBy=multi-user.target

But according to http://www.freedesktop.org/wiki/Software/systemd/timedated it probably should contain instead:

[Unit]
BindTo=systemd-timedated-ntp.target

[Install]
WantedBy=systemd-timedated-ntp.target

So that it can be controlled automatically using the systemd-timedated API (used by gnome-control-center, for example).

Additional info:
* openntpd 3.9p1-15
This task depends upon

Closed by  Dave Reisner (falconindy)
Monday, 20 August 2012, 18:01 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed the larger problem and added ntp-units.d files for ntp, openntpd, and chrony.
Comment by Dave Reisner (falconindy) - Saturday, 09 June 2012, 22:33 GMT
Using that WantedBy target instead of multi-user.target means that openntpd will never start if you aren't using systemd-timedated.
Comment by Rodrigo Rivas Costa (rodrigorc) - Sunday, 10 June 2012, 08:21 GMT
But systemd-timedated is installed by default with systemd. And it is a DBus-activatable service, so you don't even need to explicitly enable it. So, unless you mask it, if you use systemd, you _are_ using systemd-timedated.

Anyway, the systemd-timedated daemon doesn't even need to be started. You just need to enable the "systemd-timedated-ntp.target". This target is WantedBy multi-user.target, so any service that depends on it will be started automatically.

The systemd-timedated daemon is only used to enabe/disable the systemd-timedated-ntp.target via the DBus API.

Maybe the "systemd-timedated-ntp.target" should be enabled by default, I really can't tell. But IMHO, if you switch to systemd, it is better to switch to the systemd way of doing things.
Comment by Rodrigo Rivas Costa (rodrigorc) - Sunday, 10 June 2012, 20:46 GMT
Oh, my! It looks that the bug title is all wrong! Could please someone edit it into something along the lines of:

[openntpd] systemd unit should depend on systemd-timedated-ntp.target

TIA!
Comment by Dave Reisner (falconindy) - Sunday, 10 June 2012, 21:07 GMT
> if you use systemd, you _are_ using systemd-timedated.
No, this is completely false. It's entirely possible to use systemd, even with an NTP daemon, without ever having this extra daemon running.

> The systemd-timedated daemon is only used to enabe/disable the systemd-timedated-ntp.target via the DBus API.
It's meant as an abstraction for non-root users to be able to disable/enable NTP via dbus.

I see no problem with adding the BindTo= to pull in the extra target, but I'm not changing the WantedBy and forcing people to magically figure out that they need an extra target in order for their NTP daemon to start up as they expect.
Comment by Rodrigo Rivas Costa (rodrigorc) - Monday, 11 June 2012, 08:38 GMT
>> if you use systemd, you _are_ using systemd-timedated.
> No, this is completely false. It's entirely possible to use systemd, even with an NTP daemon, without ever having this extra daemon running.

Of course it is possible. But, as I said before, unless you mask systemd-timedated.service, it will be started automatically whenever you open the gnome time/date applet, for example, but the "Use network time" switch will simply do nothing.

And also, the daemon is not needed at all for openntpd to be running: openntpd would depend on systemd-timedated-ntp.target, not systemd-timedated.service. They are 2 different units.

Naturally, anybody can copy the openntpd.service to /etc/systemd/system and edit it as they see fit. But we are talking about defaults here.

>> The systemd-timedated daemon is only used to enabe/disable the systemd-timedated-ntp.target via the DBus API.
> It's meant as an abstraction for non-root users to be able to disable/enable NTP via dbus.

Yes, an abstraction that simply will not work without my suggested changes.

> I see no problem with adding the BindTo= to pull in the extra target, [...]

But with BindTo= and without WantedBy=, that will make openntpd to stop whenever the DBus API tells it to, but not to start when it is needed again.

> but I'm not changing the WantedBy and forcing people to magically figure out that
> they need an extra target in order for their NTP daemon to start up as they expect.

Not so magically.
a) it can be said in the Wiki.
b) the GUI for "Use network time" will work automatically, instead of doing nothing.
c) it is obvious if you read the openntpd.service.
d) the systemd-timedated-ntp.target _could_ be enabled by default in systemd: openntpd.service is wanted by systemd-timedated-ntp.target; systemd-timedated-ntp.target is wanted by multi-user.target.

Note that the same is happening with other daemons... It took me a while to notice that I had to enable the bluetooth.target for the bluetooth.service to be started (BTW, I think it should be enabled by default, also). But that's the systemd way!

Really, without this configuration, the existence of systemd-timedated is just meaningless.
Comment by Dave Reisner (falconindy) - Wednesday, 04 July 2012, 04:05 GMT
With 186, this is all invalid. Upstream has gone a different direction and systemd-timedated-ntp.target no longer exists (which is good).

We'll need to ship a .list file with NTP implementations to denote valid NTP services, and that should just take care of this.

Relevant: http://cgit.freedesktop.org/systemd/systemd/commit/?id=b32d167503b0d98
Comment by Dave Reisner (falconindy) - Monday, 20 August 2012, 18:00 GMT
I've added ntp-units.d files to all 3 NTP implementations in the repos: ntp, openntpd, and chrony. This should work as intended now.

Loading...