bisect-kit: cope with incorrect board entry in swarming database
BUG=b:196499726
TEST=./cros_helper.py allocate_dut --sku dratini_IntelR_CoreTM_i5_10310U_CPU_1_70GHz_2_8GB --version_hint R94-14130.0.0,R94-14138.0.0 --builder_hint hatch-borealis
Change-Id: Iaefe45acc6114332269d33cffa85fc54dc8ab0d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/bisect-kit/+/3093969
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Auto-Submit: Kuang-che Wu <kcwu@chromium.org>
Commit-Queue: Zheng-Jie Chang <zjchang@chromium.org>
Reviewed-by: Zheng-Jie Chang <zjchang@chromium.org>
diff --git a/cros_helper.py b/cros_helper.py
index 2b97f00..fc148df 100755
--- a/cros_helper.py
+++ b/cros_helper.py
@@ -121,16 +121,17 @@
constraints = [dimension]
if pool:
constraints.append('label-pool:' + pool)
- bots = cros_lab_util.swarming_bots_list(constraints, is_busy=None, limit=1)
- if not bots:
- continue
- board = bots[0]['dimensions']['label-board'][0]
- if board not in boards_with_prebuilt:
- logger.warning(
- 'dimension=%s (board=%s) does not have corresponding '
- 'prebuilt image, ignore', dimension, board)
- continue
- result.add(dimension)
+ # Ideally, we need only one result. Here we get more (limit=10) in order to
+ # cope with incorrect metadata in swarming database (b/196499726).
+ bots = cros_lab_util.swarming_bots_list(constraints, is_busy=None, limit=10)
+ for bot in bots:
+ board = bot['dimensions']['label-board'][0]
+ if board not in boards_with_prebuilt:
+ logger.warning(
+ 'dimension=%s (board=%s) does not have corresponding '
+ 'prebuilt image, ignore', dimension, board)
+ continue
+ result.add(dimension)
return list(result)