Bug 1286969

Summary: ntpstat reports synchronized even when the local ntpd doesn't synchronize with any time server.
Product: Red Hat Enterprise Linux 6 Reporter: Masahiro Matsuya <mmatsuya>
Component: ntpAssignee: Miroslav Lichvar <mlichvar>
Status: CLOSED ERRATA QA Contact: Jakub Prokes <jprokes>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.6CC: akarande, jprokes, ovasik
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: ntp-4.2.6p5-9.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1309594 (view as bug list) Environment:
Last Closed: 2016-05-10 20:17:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1309594    

Description Masahiro Matsuya 2015-12-01 09:14:38 UTC
Description of problem:

When ntpd starts, ntpstat reports 'unsynchronized' for a while. That's ok.
After a while, ntpd starts to sync with a time server, and ntpstat report 'synchronized'. That's ok as well.
A customer stopped the upper time servers, and ntpd lost all time servers to be synchronized. But, ntpstat keeps to report 'synchronized'.

They are going to check the status of ntpd with ntpstat command. So, their expectation is that ntpstat returns 1 (unsyncronized) when it lose all ones to be synchronized.

ntpstat checks the value of sys_leap in the local ntpd. If it's 0x11 (LEAP_NOTINSYNC), it reports unsynchronized. As far as I checked the ntp's souce code, the code to set LEAP_NOTINSYNC into sys_leap is the following only.

0 ntpd/ntp_proto.c 1717 sys_leap = LEAP_NOTINSYNC;  ## when step adjustment happen
2 ntpd/ntp_proto.c 2251 sys_leap = LEAP_NOTINSYNC;  ## N/A because LOCKCLOCK macro is not defined.
3 ntpd/ntp_proto.c 3586 sys_leap = LEAP_NOTINSYNC;  ## when ntpd starts.

So, it can be changed into LEAP_NOTINSYNC, only when a step adjustment happens.


Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux 7

How reproducible:
Always

Steps to Reproduce:
1. configure two ntp hosts (server and client) with RHEL6
2. configure the ntp client to refer to the ntp server
3. start ntpd on both and wait the sync status.
4. stop ntpd on the ntp server, and wait until the ntp client got the status of unsynchronized.
5. run ntpstat and check that it still reports synchronized.

Actual results:
ntpstat reports synchronized, after it loses all time server to be synchronized.

Expected results:
ntpstat can report unsynchronized, when it loses all time server to be synchronized.

Comment 9 Miroslav Lichvar 2015-12-07 15:48:05 UTC
The ntpstat man page has been modified to include:

When the synchronised state is reported, it means the system clock was updated at some point.  There is no timeout for this state.  It will stay there even when the source becomes unreachable and there are no other sources available. However, the reported accuracy will be slowly increasing, in the default ntpd configuration by 15 microseconds per second.

Comment 16 errata-xmlrpc 2016-05-10 20:17:47 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-0780.html