]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
task/clock: add chrony support 1288/head
authorNathan Cutler <ncutler@suse.com>
Sat, 11 Feb 2017 18:28:03 +0000 (19:28 +0100)
committerKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Thu, 2 May 2019 18:08:14 +0000 (20:08 +0200)
Signed-off-by: Nathan Cutler <ncutler@suse.com>
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@gmail.com>
teuthology/nuke/actions.py
teuthology/task/clock.py

index d994ca95c06495ff724bf1bb764bc98040408be9..b9583e8180f6ee0d295a8dd61c0baf0397cda82a 100644 (file)
@@ -396,13 +396,20 @@ def synch_clocks(remotes):
     for remote in remotes:
         remote.run(
             args=[
-                'sudo', 'service', 'ntp', 'stop',
+                'sudo', 'systemctl', 'stop', 'ntp.service', run.Raw('||'),
+                'sudo', 'systemctl', 'stop', 'ntpd.service', run.Raw('||'),
+                'sudo', 'systemctl', 'stop', 'chronyd.service',
                 run.Raw('&&'),
-                'sudo', 'ntpdate-debian',
+                'sudo', 'ntpdate-debian', run.Raw('||'),
+                'sudo', 'ntp', '-gq', run.Raw('||'),
+                'sudo', 'ntpd', '-gq', run.Raw('||'),
+                'sudo', 'chronyc', 'sources',
                 run.Raw('&&'),
                 'sudo', 'hwclock', '--systohc', '--utc',
                 run.Raw('&&'),
-                'sudo', 'service', 'ntp', 'start',
+                'sudo', 'systemctl', 'start', 'ntp.service', run.Raw('||'),
+                'sudo', 'systemctl', 'start', 'ntpd.service', run.Raw('||'),
+                'sudo', 'systemctl', 'start', 'chronyd.service',
                 run.Raw('||'),
                 'true',    # ignore errors; we may be racing with ntpd startup
             ],
index 53a349c8660e4cffbb20d62d5791c6ddd7eb79dc..69474e973447d2d87754093d6046ce6696892615 100644 (file)
@@ -3,9 +3,8 @@ Clock synchronizer
 """
 import logging
 import contextlib
-import os
 
-from ..orchestra import run
+from teuthology.orchestra import run
 
 log = logging.getLogger(__name__)
 
@@ -32,32 +31,25 @@ def task(ctx, config):
 
     log.info('Syncing clocks and checking initial clock skew...')
     for rem in ctx.cluster.remotes.iterkeys():
-        ntpconf = rem.get_file('/etc/ntp.conf')
-        servers = [
-            l.strip().split()[1] for l in open(ntpconf, 'r').readlines()
-            if l.startswith('server')
-        ]
-        os.remove(ntpconf)
-        # CentOS calls it ntpd, Xenial/Trusty are ntp.  Thanks guys.
-        args = [
-            'sudo', 'service', 'ntp', 'stop',
-            run.Raw('||'),
-            'sudo', 'service', 'ntpd', 'stop',
-            run.Raw(';'),
-            'sudo',
-            'ntpdate',
-        ]
-        args.extend(servers)
-        args.extend([
-            run.Raw(';'),
-            'sudo', 'service', 'ntp', 'start',
-            run.Raw('||'),
-            'sudo', 'service', 'ntpd', 'start',
-            run.Raw(';'),
-            'PATH=/usr/bin:/usr/sbin',
-            'ntpq', '-p',
-        ])
-        rem.run(args=args)
+        rem.run(
+            args = [
+                'sudo', 'systemctl', 'stop', 'ntp.service', run.Raw('||'),
+                'sudo', 'systemctl', 'stop', 'ntpd.service', run.Raw('||'),
+                'sudo', 'systemctl', 'stop', 'chronyd.service',
+                run.Raw(';'),
+                'sudo', 'ntpd', '-gq', run.Raw('||'),
+                'sudo', 'chronyc', 'makestep',
+                run.Raw(';'),
+                'sudo', 'systemctl', 'start', 'ntp.service', run.Raw('||'),
+                'sudo', 'systemctl', 'start', 'ntpd.service', run.Raw('||'),
+                'sudo', 'systemctl', 'start', 'chronyd.service',
+                run.Raw(';'),
+                'PATH=/usr/bin:/usr/sbin', 'ntpq', '-p', run.Raw('||'),
+                'PATH=/usr/bin:/usr/sbin', 'chronyc', 'sources',
+                run.Raw('||'),
+                'true'
+            ],
+        )
 
     try:
         yield
@@ -67,8 +59,10 @@ def task(ctx, config):
         for rem in ctx.cluster.remotes.iterkeys():
             rem.run(
                 args=[
-                    'PATH=/usr/bin:/usr/sbin',
-                    'ntpq', '-p',
+                    'PATH=/usr/bin:/usr/sbin', 'ntpq', '-p', run.Raw('||'),
+                    'PATH=/usr/bin:/usr/sbin', 'chronyc', 'sources',
+                    run.Raw('||'),
+                    'true'
                     ],
                 )
 
@@ -85,8 +79,10 @@ def check(ctx, config):
     for rem in ctx.cluster.remotes.iterkeys():
         rem.run(
             args=[
-                'PATH=/usr/bin:/usr/sbin',
-                'ntpq', '-p',
+                'PATH=/usr/bin:/usr/sbin', 'ntpq', '-p', run.Raw('||'),
+                'PATH=/usr/bin:/usr/sbin', 'chronyc', 'sources',
+                run.Raw('||'),
+                'true'
                 ],
             )
 
@@ -98,7 +94,9 @@ def check(ctx, config):
         for rem in ctx.cluster.remotes.iterkeys():
             rem.run(
                 args=[
-                    'PATH=/usr/bin:/usr/sbin',
-                    'ntpq', '-p',
+                    'PATH=/usr/bin:/usr/sbin', 'ntpq', '-p', run.Raw('||'),
+                    'PATH=/usr/bin:/usr/sbin', 'chronyc', 'sources',
+                    run.Raw('||'),
+                    'true'
                     ],
                 )