From 4da6c0c1116e97f50bca54db4a687717c782531c Mon Sep 17 00:00:00 2001 From: Stanislaw Bogatkin Date: Tue, 28 Mar 2017 16:54:04 +0300 Subject: [PATCH] Remove requirement to have strong reachability to remote server If remote server was selected as reference, it can be used as time source, so there are no big problem if it flaps. Change-Id: I01fa7acde7c9cd97245e8b2bf8ca31f3c62d6479 Related-Bug: #1656020 --- devops/helpers/ntp.py | 10 +++++++--- devops/tests/helpers/test_ntp.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/devops/helpers/ntp.py b/devops/helpers/ntp.py index 4ba51ecb..6315533a 100644 --- a/devops/helpers/ntp.py +++ b/devops/helpers/ntp.py @@ -119,7 +119,7 @@ class BaseNtp(AbstractNtp): for peer in peers: p = peer.split() remote = str(p[0]) - reach = int(p[6], 8) # From octal to int + # reach = int(p[6], 8) # From octal to int offset = float(p[8]) jitter = float(p[9]) @@ -134,8 +134,12 @@ class BaseNtp(AbstractNtp): # 3. reachability bit array should have '1' at least in # two lower bits as the last two successful checks - if reach & 3 != 3: - continue + # TODO(sbog): we should improve this, as unstable reference + # is still a reference and can be used for time sync. Moreover, + # if there are other servers which can easily be a reference + # one, that reachability of current one is not a problem at all. + # if reach & 3 != 3: + # continue return True return False diff --git a/devops/tests/helpers/test_ntp.py b/devops/tests/helpers/test_ntp.py index bdaf7b38..cf6284a6 100644 --- a/devops/tests/helpers/test_ntp.py +++ b/devops/tests/helpers/test_ntp.py @@ -155,7 +155,7 @@ class TestNtpInitscript(NtpTestCase): ntp_init = ntp.NtpInitscript(self.remote_mock, 'node') assert ntp_init._get_sync_complete() is True - def test_get_sync_complete_false(self): + def test_get_sync_complete_with_unstable_peer(self): self.remote_mock.execute.side_effect = ( self.make_exec_result('/etc/init.d/ntp'), self.make_exec_result("""\ @@ -169,7 +169,7 @@ class TestNtpInitscript(NtpTestCase): """)) ntp_init = ntp.NtpInitscript(self.remote_mock, 'node') - assert ntp_init._get_sync_complete() is False + assert ntp_init._get_sync_complete() is True def test_wait_peer(self): ntp_init = ntp.NtpInitscript(self.remote_mock, 'node')