From 96e89d30ec5f912f3c1b4844328e0966a2266e05 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Thu, 12 Jan 2012 12:57:22 -0800 Subject: [PATCH] kernel: loop reconnecting in case we race with shutdown Previously, if we reconnected before shutdown completed we asserted that the kernel did not boot into the new version, when we just needed to wait for the machine to reboot. --- teuthology/task/kernel.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/teuthology/task/kernel.py b/teuthology/task/kernel.py index 6df46ffe142bf..b3a8574aa7a5a 100644 --- a/teuthology/task/kernel.py +++ b/teuthology/task/kernel.py @@ -176,6 +176,23 @@ def install_and_reboot(ctx, config): log.debug('Waiting for install on %s to complete...', name) proc.exitstatus.get() +def wait_for_reboot(ctx, need_install, timeout): + """ + Loop reconnecting and checking kernel versions until + they're all correct or the timeout is exceeded. + """ + import time + starttime = time.time() + while need_install: + teuthology.reconnect(ctx, timeout) + for client in need_install.keys(): + log.info('Checking client {client} for new kernel version...'.format(client=client)) + if need_to_install(ctx, client, need_install[client]): + assert time.time() - starttime < timeout, \ + 'failed to install new kernel version within timeout' + else: + del need_install[client] + time.sleep(1) def task(ctx, config): """ @@ -243,11 +260,6 @@ def task(ctx, config): if need_to_install(ctx, role, sha1): need_install[role] = sha1 - if len(need_install) > 0: + if need_install: install_and_reboot(ctx, need_install) - teuthology.reconnect(ctx, timeout) - - for client, sha1 in need_install.iteritems(): - log.info('Checking client {client} for new kernel version...'.format(client=client)) - assert not need_to_install(ctx, client, sha1), \ - "Client did not boot to the new kernel!" + wait_for_reboot(ctx, need_install, timeout) -- 2.39.5