aboutsummaryrefslogtreecommitdiff
path: root/lock_machine.py
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2020-05-02 10:28:55 -0700
committerGeorge Burgess <gbiv@chromium.org>2020-05-04 19:40:05 +0000
commit900d6e7f33499bd70cdac8302917d37f812b7ffc (patch)
treef58a9b30dedbbcd55a3f26a02dbddb3a9eac8f23 /lock_machine.py
parent47c8f96553e22616164ec43b806c0ae75c1bf159 (diff)
downloadtoolchain-utils-900d6e7f33499bd70cdac8302917d37f812b7ffc.tar.gz
lock_machine: shout when our `swarming` command dies
When I tried to run crosperf without proper `swarming.py` authentication, crosperf said the machine I wanted to use wasn't available in skylab. It'd be better if we reported that we couldn't tell if the machine was/wasn't in skylab due to the tool we're using failing. Looks like this script can fail for a number of other reasons, too, so throwing our hands up is likely going to often be our best bet. BUG=None TEST=ran without auth; exception was thrown. ran with; things worked. Change-Id: I4d0e4ec70eddb3a7836686eef819e6175a730756 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2177063 Reviewed-by: Bob Haarman <inglorion@chromium.org> Tested-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'lock_machine.py')
-rwxr-xr-xlock_machine.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/lock_machine.py b/lock_machine.py
index 8588ebfd..dc494142 100755
--- a/lock_machine.py
+++ b/lock_machine.py
@@ -386,7 +386,11 @@ class LockManager(object):
(swarming,
credential,
machine.rstrip('.cros')))
- ret_tup = self.ce.RunCommandWOutput(cmd)
+ exit_code, stdout, stderr = self.ce.RunCommandWOutput(cmd)
+ if exit_code:
+ raise ValueError(
+ 'Querying bots failed (2); stdout: %r; stderr: %r' % (stdout, stderr))
+
# The command will return a json output as stdout. If machine not in skylab
# stdout will look like this:
# {
@@ -395,10 +399,7 @@ class LockManager(object):
# }
# Otherwise there will be a tuple starting with 'items', we simply detect
# this keyword for result.
- if 'items' not in ret_tup[1]:
- return False
- else:
- return True
+ return 'items' in stdout
def LeaseSkylabMachine(self, machine):
"""Run command to lease dut from skylab.