clock: print skew with ntp servers to log to help debug time issues

This commit is contained in:
Sage Weil 2012-07-18 13:44:59 -07:00
parent 55847fc298
commit c49daeca2f

View File

@ -1,9 +1,11 @@
import logging
import contextlib
from ..orchestra import run
log = logging.getLogger(__name__)
@contextlib.contextmanager
def task(ctx, config):
"""
Sync or skew clock
@ -20,34 +22,38 @@ def task(ctx, config):
to sync.
To skew, we should allow something like:
tasks:
- clock:
mon.0: -2
client.1: 2
- ceph:
- interactive:
"""
ctx.cluster.run(
args=[
'sudo',
'service', 'ntp', 'stop',
run.Raw(';'),
'sudo',
'ntpdate',
'clock1.dreamhost.com',
'clock2.dreamhost.com',
'clock3.dreamhost.com',
run.Raw(';'),
'sudo',
'service', 'ntp', 'start',
run.Raw('||'),
'true'
],
log.info('Syncing clocks and checking initial clock skew...')
for rem in ctx.cluster.remotes.iterkeys():
rem.run(
args=[
'sudo',
'service', 'ntp', 'stop',
run.Raw(';'),
'sudo',
'ntpdate',
'clock1.dreamhost.com',
'clock2.dreamhost.com',
'clock3.dreamhost.com',
run.Raw(';'),
'sudo',
'service', 'ntp', 'start',
run.Raw(';'),
'ntpdc', '-p',
],
logger=log.getChild(rem.name),
)
# TODO do the skew
#for role, skew in config.iteritems():
try:
yield
finally:
log.info('Checking final clock skew...')
for rem in ctx.cluster.remotes.iterkeys():
rem.run(
args=[
'ntpdc', '-p',
],
logger=log.getChild(rem.name),
)