Bug 617328 - Providing native systemd file for upcoming F14 Feature Systemd
Providing native systemd file for upcoming F14 Feature Systemd
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: ntp (Show other bugs)
14
All Linux
low Severity medium
: ---
: ---
Assigned To: Miroslav Lichvar
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-07-22 15:10 EDT by Jóhann B. Guðmundsson
Modified: 2010-09-08 00:38 EDT (History)
5 users (show)

See Also:
Fixed In Version: ntp-4.2.6p2-4.fc14
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-08-23 09:32:31 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Native systemd file for ntpd (137 bytes, application/octet-stream)
2010-07-22 15:10 EDT, Jóhann B. Guðmundsson
no flags Details

  None (edit)
Description Jóhann B. Guðmundsson 2010-07-22 15:10:32 EDT
Created attachment 433784 [details]
Native systemd file for ntpd

Description of problem:

The attached file is a native systemd file for upcoming F14 Feature [1]

Please read [2] on how to installing systemd Service files.

1.http://fedoraproject.org/wiki/Features/systemd
2.https://fedoraproject.org/wiki/User:Johannbg/QA/Systemd/Daemon#Installing_Systemd_Service_Files

If you have any question dont hesitate to ask them on this bug report.

Thank you.


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 1 Miroslav Lichvar 2010-07-23 08:03:43 EDT
Two questions:

Are the options in the service file supposed to be configurable by user? The current service starts ntpd with "-u ntp:ntp -g" options by default (set in /etc/sysconfig/ntpd).

How does this work with ntpdate service, will it be started after ntpdate has finished? Currently it doesn't work without NETWORKWAIT=yes, see bug #445229.
Comment 2 Bug Zapper 2010-07-30 08:45:27 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 14 development cycle.
Changing version to '14'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 3 Lennart Poettering 2010-08-10 09:42:43 EDT
Miroslav, it is relatively easy to support /etc/sysconfig/ntpd. Simply add "EnvironmentFile=/etc/sysconfig/ntpd" to the .service file. This will merge the sysconfig variables from that file into the normal environment.

Then, you may use $OPTIONS in the command line in the .service file to refer to this variable.

That said I don't think that -u or -p or -g is anything the user should be able to configure, and hence I'd actually suggest removing the sysconfig file altogether.

It would be easy to wirte a service for ntpdate too. You could then simply add an "After=network.target" which will make sure it is run only after either NetworkManager or some other network script is configured.

BTW, the ntpd.service file could use one more addition: It should have WantedBy=rtc-set.target too, for better coapat with LSB init scripts requesting $time.

So, the resulting .service file could look something like this:

<snip>
[Unit]
Description=Network Time Service
After=syslog.target

[Service]
EnvironmentFile=/etc/sysconfig/ntpd
ExecStart=/usr/sbin/ntpd -n -u ntp:ntp -p /var/run/ntpd.pid -g $OPTIONS

[Install]
WantedBy=multi-user.target rtc-set.target
</snip>
Comment 4 Miroslav Lichvar 2010-08-10 10:00:35 EDT
Ok, thanks.

ntpdate and ntpd must not run at the same time, so I need to add an After to the ntpd service file?

Will be then ntpd started even when there is no network configured? (this is useful to load the drift file and to have refclocks working)
Comment 5 Miroslav Lichvar 2010-08-11 08:43:25 EDT
Also, the current ntpdate script does more than just run ntpdate, it also sets hwclock if configured to do so and looks for NTP servers in various file, this requires a bit of shell scripting.

Can this be done in native systemd script or does it need to be wrapped in another shell script?

Pointer to a similar script would be helpful.
Comment 6 Lennart Poettering 2010-08-11 09:46:18 EDT
If it doesn't make sense to run both ntpdate and ntpd at the same boot then a "Conflicts=ntpdate.service" in ntp.service sounds appropriate. If it does make sense to run them both, but not at the same instant, then an After= or Before= would make sense.

By hooking ntp into "multi-user.target" it is started on boot, regardless whether there is network. If you want to make sure that ntp is normally started after the network is around if it enabled you probably should add an "After=network.target" here though.

Regarding shell scripts: it is fine to run a shell script instead of an actual binary from the service files. In fact, we already do this for rc.sysinit itself which is started from sysinit.service.
Comment 7 Lennart Poettering 2010-08-11 09:50:16 EDT
BTW, it is not sufficient to just drop the .service files into /lib/systemd/system. It is also necessary to enable it when upgrading from an old sysv-only rpm. How to implement that in the spec file with minimal work is documented in daemon(7):

http://0pointer.de/public/systemd-man/daemon.html#id2562029
Comment 8 Miroslav Lichvar 2010-08-20 06:10:53 EDT
I'm trying to boot with this ntpdate.service:

[Unit]
Description=Set time via NTP
After=syslog.target network.target

[Service]
Type=finish
ExecStart=/etc/init.d/ntpdate start
ValidNoProcess=yes

[Install]
WantedBy=multi-user.target


But it fails as it's started before NetworkManager has configured a network interface. I was hoping with a native unit file we could finally fix bug #445229, and now it seems it doesn't work even with the NETWORKWAIT=yes workaround.

Any hints?
Comment 9 Miroslav Lichvar 2010-08-23 09:32:31 EDT
The systemd support is now in ntp-4.2.6p2-2.fc14.

The ntpdate script will retry few times in increasing intervals before giving up. Please let me know if there is a better solution for this.
Comment 10 Fedora Update System 2010-08-23 09:35:50 EDT
ntp-4.2.6p2-2.fc14 has been submitted as an update for Fedora 14.
http://admin.fedoraproject.org/updates/ntp-4.2.6p2-2.fc14
Comment 11 Fedora Update System 2010-08-26 06:35:51 EDT
ntp-4.2.6p2-3.fc14 has been submitted as an update for Fedora 14.
http://admin.fedoraproject.org/updates/ntp-4.2.6p2-3.fc14
Comment 12 Fedora Update System 2010-08-27 13:32:18 EDT
ntp-4.2.6p2-4.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/ntp-4.2.6p2-4.fc14
Comment 13 Lennart Poettering 2010-09-06 05:20:25 EDT
(In reply to comment #8)

> But it fails as it's started before NetworkManager has configured a network
> interface. I was hoping with a native unit file we could finally fix bug
> #445229, and now it seems it doesn't work even with the NETWORKWAIT=yes
> workaround.
> 
> Any hints?

Hmm, if it has After=network.target is added there, and NETWORKWAIT=yes is set too, then it should actually be synchronized properly and ntpdate should be run only after thenetwork is up. Not sure why that is wrong. Could you open a new bug abaout that and attach the "systemctl dump" output of yours?
Comment 14 Miroslav Lichvar 2010-09-06 06:39:32 EDT
I think the problem is that the NetworkManager systemd service doesn't support the NETWORKWAIT option.

Maybe a new oneshot service could be added to the NM package that would run the nm-online command and which could be specified in other services' After?
Comment 15 Fedora Update System 2010-09-08 00:38:27 EDT
ntp-4.2.6p2-4.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

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