Bug 787042 - chronyd fails to start when the NTP-Server is already present in /etc/chrony.conf
Summary: chronyd fails to start when the NTP-Server is already present in /etc/chrony....
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: chrony
Version: 16
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Miroslav Lichvar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 787477 788935 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-02-03 01:27 UTC by JM
Modified: 2012-08-07 11:14 UTC (History)
4 users (show)

Fixed In Version: chrony-1.26-5.20110831gitb088b7.fc16
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-02-22 02:01:01 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description JM 2012-02-03 01:27:49 UTC
systemctl start chronyd.service

fails to start when the NTP-Server from

/var/lib/dhclient/chrony.servers.*

is already present in 

/etc/chrony.conf

So in the moment the same NTP-Server can't be part of /etc/chrony.conf and /var/lib/dhclient/chrony.servers.*

I guess a better behavior would be to ignore that the NTP-Server is already present and then start chronyd.

Comment 1 Miroslav Lichvar 2012-02-03 12:07:08 UTC
A workaround is to set PEERNTP=no in /etc/sysconfig/network to ignore the NTP servers from DHCP.

Proper fix will need to check and remember which servers were successfully added, so the server from chrony.conf is not removed on dhclient down event with others.

Comment 2 Miroslav Lichvar 2012-02-09 10:53:17 UTC
*** Bug 788935 has been marked as a duplicate of this bug. ***

Comment 3 Fedora Update System 2012-02-10 16:56:16 UTC
chrony-1.26-4.20110831gitb088b7.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/chrony-1.26-4.20110831gitb088b7.fc16

Comment 4 Fedora Update System 2012-02-10 21:58:16 UTC
Package chrony-1.26-4.20110831gitb088b7.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing chrony-1.26-4.20110831gitb088b7.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-1531/chrony-1.26-4.20110831gitb088b7.fc16
then log in and leave karma (feedback).

Comment 5 JM 2012-02-11 15:30:42 UTC
The patch fixed the problem but creates a new one :-), the file

/var/lib/dhclient/chrony.added_servers

grows, which means during startup even old NTP servers are added to chrony. I tried it, I switched the NTP-Servers which the DHCP-Server offers and chrony is now using the old and the new NTP-Servers side by side that's actually not what I want, the NTP-Servers which the DHCP-Server offers and the NTP-Servers from /etc/chrony.conf should be the only time source for the client. I guess it would be better to clear /var/lib/dhclient/chrony.added_servers with every startup of chrony? In the moment it's not a big problem, because I don't switch NTP-Servers daily :-).

Comment 6 JM 2012-02-11 16:00:58 UTC
Ignore my last comment, the file

/var/lib/dhclient/chrony.added_servers

grows (that's correct) but chrony is using only the NTP-Servers which the DHCP-Server offers and the NTP-Servers from /etc/chrony.conf.

The problem was that I changed the NTP-Server in the DHCP-Server and then I simply restarted the NetworkManager on the client with 

service NetworkManager restart

which in the end calls (I guess?)

/etc/dhcp/dhclient.d/chrony.sh

and the script just adds the new NTP-Server to chrony but

service chronyd restart

fixed the problem. Hmm… but what happens when the Client requests a new IP (without reboot) and the DHCP-Servers offers the same IP but a new NTP-Server? Does the DHCP request restarts chrony as well?

Comment 7 Miroslav Lichvar 2012-02-13 11:25:37 UTC
The chrony daemon is not restarted on DHCP changes, the NTP servers are added and removed by chronyc.

There is a bug in NM that it sometimes doesn't call the dispatcher script on service restart, you might be hitting that (bug #517082).

The case when the same DHCP starts advertising different NTP servers might not be handled correctly though. Can you try changing the following in /etc/dhcp/dhclient.d/chrony.sh

                /usr/libexec/chrony-helper is-running &&
                        /usr/libexec/chrony-helper add-dhclient-servers || :

to

                /usr/libexec/chrony-helper is-running &&
                        /usr/libexec/chrony-helper add-dhclient-servers &&
                        /usr/libexec/chrony-helper remove-dhclient-servers || :

and see if that fixes the problem?

Comment 8 JM 2012-02-14 19:53:09 UTC
Yes, the modification from comment #7 fixed the problem.

Comment 9 Fedora Update System 2012-02-15 14:08:26 UTC
chrony-1.26-5.20110831gitb088b7.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/chrony-1.26-5.20110831gitb088b7.fc16

Comment 10 Fedora Update System 2012-02-22 02:01:01 UTC
chrony-1.26-5.20110831gitb088b7.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 11 Bojan Smojver 2012-04-10 05:33:38 UTC
There is actually a bit more subtle problem that is still present.

If one configures chrony with the same time server as the one that comes from DHCP, but with iburst option, the one from DHCP (that always comes without iburst) will win. This then usually means that for a while, the system will have incorrect time after boot.

So, if one uses Kerberos, for instance, the ticket issued upon login will be wrong and it actually won't work, due to clock skew that is too great. Ditto building something using make - it may produce warnings about things being from the future (if you live in UTC+ zone and your hardware clock is set to UTC).

Is it possible to always use the configured config (i.e. from /etc/chrony.conf) in place of DHCP, if the servers happen to be the same? It seems to me that if someone went to the trouble of configuring something by hand, they probably want exactly that.

Comment 12 Miroslav Lichvar 2012-04-10 11:52:57 UTC
Hm, I don't see that. The chronyc command adding the server from DHCP should fail as chronyd won't allow to add the same server for second time. How much time there was between chronyd start and dhclient getting a lease?

Also, options for the DHCP servers can be set in /etc/sysconfig/network, e.g.
NTPSERVERARGS=iburst

Comment 13 Bojan Smojver 2012-04-10 13:03:05 UTC
(In reply to comment #12)
> Hm, I don't see that. The chronyc command adding the server from DHCP should
> fail as chronyd won't allow to add the same server for second time.

OK, to me it looks as if the dhcp version, without iburst, is winning, which is causing sync delay. But maybe I am confused.

> How much
> time there was between chronyd start and dhclient getting a lease?

Many minutes. Enough to login into Gnome, open Evo (which uses krb5 auth) and several shells, and start a new build, for instance.

> Also, options for the DHCP servers can be set in /etc/sysconfig/network, e.g.
> NTPSERVERARGS=iburst

OK, thanks for the tip. I worked around for now by using PEERNTP=no.

Comment 14 Miroslav Lichvar 2012-04-10 13:59:59 UTC
(In reply to comment #13)
> (In reply to comment #12)
 > > How much
> > time there was between chronyd start and dhclient getting a lease?
> 
> Many minutes. Enough to login into Gnome, open Evo (which uses krb5 auth) and
> several shells, and start a new build, for instance.

If there are several minutes when chronyd configured with an iburst server is without network, there will be only 8 packets sent quickly (to nowhere) and then the polling interval will be 64 seconds and will increase slowly. I.e. the iburst options is useful only when network is available soon after chronyd was started, perhaps up to 40 seconds.

Comment 15 Bojan Smojver 2012-04-11 03:29:47 UTC
(In reply to comment #14)

> If there are several minutes when chronyd configured with an iburst server is
> without network, there will be only 8 packets sent quickly (to nowhere) and
> then the polling interval will be 64 seconds and will increase slowly. I.e. the
> iburst options is useful only when network is available soon after chronyd was
> started, perhaps up to 40 seconds.

Sorry, I think I misunderstood your previous question. Dhclient gets a lease within seconds. Long time after that chronyd reports that it had to step up the clock by a large amount:
-----------------
Apr 11 13:04:21 shrek chronyd[1172]: Selected source <IP>
Apr 11 13:04:21 shrek chronyd[1172]: System clock wrong by -39601.012002 seconds
, adjustment started
Apr 11 13:04:21 shrek chronyd[1172]: System clock was stepped by -39601.012 seco
nds
-----------------

Log entries just before those have "Apr 12 00:04:21", hence the 39,600 seconds difference.

Anyhow, with NTPSERVERARGS=iburst in my ifcfg-eth0 file, it all works great. I can see with 'chronyc sources' that sync to my time server happens within seconds.

Comment 16 Miroslav Lichvar 2012-08-07 11:14:59 UTC
*** Bug 787477 has been marked as a duplicate of this bug. ***


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