From patchwork Fri Jun 1 05:19:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 9067 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0FFEB23E57 for ; Fri, 1 Jun 2012 05:19:15 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id CB38CA18672 for ; Fri, 1 Jun 2012 05:19:14 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so1534052yhp.11 for ; Thu, 31 May 2012 22:19:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=IRK/uUmnTpaHFWwcTBlJf+BTlghWLeP8ofjereA9vXU=; b=ZKhx7rv19TMGIBdOx7ZFQFQuQVFdhlLcaIabKw82nFKLEVPYYFDujwBz3VKXrlhCj+ A8dLqlWBnIFZzDp6QNoMHTA+FKgR+bP7YMe7/18VSWg5CbWHRo0+cZbLaJ4CnwUfyhIt HUBLQoKiL9cKz3xcqDVCjyHn1k+LkLs8bataW16etvtCNhwZtemYGkaOwKyfSUiSsqhW F0+1ObGfuGu2eEpjX8cZyRgIfTCy8yyzQfsI3BgPd+453j3HXF3wsZrgATcDK+BfW289 0OSjDkQGGzz6cv3ab37DAhgYuWSOmmabQE/GhdMy2hqCqmvCSVmTSdX2wX9oD9ecmOsP 9HqA== Received: by 10.50.163.99 with SMTP id yh3mr204921igb.53.1338527954421; Thu, 31 May 2012 22:19:14 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp296571ibb; Thu, 31 May 2012 22:19:13 -0700 (PDT) Received: by 10.14.185.144 with SMTP id u16mr621355eem.232.1338527952656; Thu, 31 May 2012 22:19:12 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id z9si6252555wiv.46.2012.05.31.22.19.12 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 May 2012 22:19:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1SaKGV-0000gr-UE for ; Fri, 01 Jun 2012 05:19:11 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id D5E98E0A41 for ; Fri, 1 Jun 2012 05:19:11 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 312 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 312: watch for various messages from the connection_command that indicate Message-Id: <20120601051911.16541.52172.launchpad@ackee.canonical.com> Date: Fri, 01 Jun 2012 05:19:11 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15342"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 3e004734ce985002dfc4d017d6e422714b146441 X-Gm-Message-State: ALoCoQkphoCRbupClLJrdx8hJK9nxVNdq+hyXrfRdoL4R4wVB0hhiuDOMahV9gcHXbIQWgnVyZcI Merge authors: Michael Hudson-Doyle (mwhudson) ------------------------------------------------------------ revno: 312 [merge] committer: Michael Hudson-Doyle branch nick: trunk timestamp: Fri 2012-06-01 17:17:36 +1200 message: watch for various messages from the connection_command that indicate how successful the connection attempt has been, and do various things in response. apologies for the lack of review, the code has been well tested on staging though modified: lava_dispatcher/client/master.py --- lp:lava-dispatcher https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk You are subscribed to branch lp:lava-dispatcher. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription === modified file 'lava_dispatcher/client/master.py' --- lava_dispatcher/client/master.py 2012-05-31 08:26:23 +0000 +++ lava_dispatcher/client/master.py 2012-06-01 04:40:24 +0000 @@ -297,13 +297,58 @@ pre_connect = self.device_option("pre_connect_command") if pre_connect: logging_system(pre_connect) + self.proc = self._connect_carefully() + atexit.register(self._close_logging_spawn) + + def _connect_carefully(self): cmd = self.device_option("connection_command") - proc = logging_spawn(cmd, timeout=1200) - proc.logfile_read = self.sio - #serial can be slow, races do funny things if you don't increase delay - proc.delaybeforesend=1 - self.proc = proc - atexit.register(self._close_logging_spawn) + + retry_count = 0 + retry_limit = 3 + + port_stuck_message = 'Data Buffering Suspended\.' + hot_key_message = 'Type the hot key to suspend the connection:.*\r' + conn_closed_message = 'Connection closed by foreign host\.' + + expectations = { + port_stuck_message: 'reset-port', + 'Connected\.\r': 'all-good', + hot_key_message: 'all-good', + conn_closed_message: 'retry', + pexpect.TIMEOUT: 'all-good', + } + patterns = [] + results = [] + for pattern, result in expectations.items(): + patterns.append(pattern) + results.append(result) + + while retry_count < retry_limit: + proc = logging_spawn(cmd, timeout=1200) + proc.logfile_read = self.sio + #serial can be slow, races do funny things if you don't increase delay + proc.delaybeforesend=1 + logging.info('Attempting to connect to device') + match = proc.expect(patterns, timeout=10) + result = results[match] + logging.info('Matched %r which means %s', patterns[match], result) + if result == 'retry': + proc.close(True) + retry_count += 1 + time.sleep(5) + continue + elif result == 'all-good': + return proc + elif result == 'reset-port': + reset_port = self.device_option("reset_port_command") + if reset_port: + logging_system(reset_port) + else: + raise OperationFailed("no reset_port command configured") + proc.close(True) + retry_count += 1 + time.sleep(5) + raise OperationFailed("could execute connection_command successfully") @property def master_str(self):