From 98cc1b835c569e1ea71066d8bd0767ff915ba74c Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Fri, 18 Jan 2013 17:43:47 +0000 Subject: [PATCH] task: mon_clock_skew_check: add option to run at least one timecheck at-least-once Runs at least once, even if we are told to stop. (default: True) at-least-once-timeout If we were told to stop but we are attempting to run at least once, timeout after this many seconds. (default: 300) Fixes: #3854 Signed-off-by: Joao Eduardo Luis --- teuthology/task/mon_clock_skew_check.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/teuthology/task/mon_clock_skew_check.py b/teuthology/task/mon_clock_skew_check.py index facd07bbc3b33..5504a1bc714cc 100644 --- a/teuthology/task/mon_clock_skew_check.py +++ b/teuthology/task/mon_clock_skew_check.py @@ -32,6 +32,12 @@ class ClockSkewCheck: expecting it, or if no skew is detected and we were expecting it. (default: False) + at-least-once Runs at least once, even if we are told to stop. + (default: True) + at-least-once-timeout If we were told to stop but we are attempting to + run at least once, timeout after this many seconds. + (default: 300) + Example: Expect a skew higher than 0.05 seconds, but only report it without failing the teuthology run. @@ -58,6 +64,8 @@ class ClockSkewCheck: self.max_skew = float(self.config.get('max-skew', 0.05)) self.expect_skew = self.config.get('expect-skew', False) self.never_fail = self.config.get('never-fail', False) + self.at_least_once = self.config.get('at-least-once', True) + self.at_least_once_timeout = self.config.get('at-least-once-timeout', 300.0) def info(self, x): self.logger.info(x) @@ -71,7 +79,16 @@ class ClockSkewCheck: def do_check(self): self.info('start checking for clock skews') skews = dict() - while not self.stopping: + ran_once = False + started_on = time.time() + + while not self.stopping or (self.at_least_once and not ran_once): + + if self.at_least_once and not ran_once and self.stopping: + if self.at_least_once_timeout > 0.0: + assert time.time() - started_on < self.at_least_once_timeout, \ + 'failed to obtain a timecheck before timeout expired' + quorum_size = len(teuthology.get_mon_names(self.ctx)) self.manager.wait_for_mon_quorum_size(quorum_size) @@ -97,6 +114,11 @@ class ClockSkewCheck: else: self.warn('unexpected skew: {str}'.format(str=log_str)) + if len(health['timechecks']) == 0: + self.info('no timechecks available just yet') + else: + ran_once = True + if (self.check_interval > 0.0): time.sleep(self.check_interval) -- 2.39.5