Skip to content

Commit

Permalink
Merge pull request ceph#1288 from kshtsk/suse-chrony
Browse files Browse the repository at this point in the history
task/clock: add chrony support
  • Loading branch information
zmc authored May 3, 2019
2 parents 2ede50a + cc62161 commit fd6205e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 37 deletions.
13 changes: 10 additions & 3 deletions teuthology/nuke/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
Expand Down
66 changes: 32 additions & 34 deletions teuthology/task/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"""
import logging
import contextlib
import os

from ..orchestra import run
from teuthology.orchestra import run

log = logging.getLogger(__name__)

Expand All @@ -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
Expand All @@ -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'
],
)

Expand All @@ -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'
],
)

Expand All @@ -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'
],
)

0 comments on commit fd6205e

Please sign in to comment.