liyujie
2025-08-28 786ff4f4ca2374bdd9177f2e24b503d43e7a3b93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
 
# Force a repair special task for any host that hasn't seen activity in
# the past day.
#
# Various scripts/cron jobs look for DUTs that aren't working.  To be
# conservative, those scripts assume that a DUT that hasn't run any jobs
# within a reasonable time interval isn't working, since some of the
# ways a DUT may be unavailable manifest as inactivity.
#
# In some cases, we'd like to be more certain as to a DUT's status.
# This script goes through the entire AFE hosts table, and identifies
# unlocked hosts that would otherwise be flagged as "not working due to
# lack of activity", and forces a repair task.
#
# We use a repair task (as opposed to verify) for various reasons:
#   + If a DUT is working, repair and verify perform the same checks,
#     and generally run in the same time.
#   + If a DUT is broken, a verify task will fail and invoke repair,
#     which will take longer than just repair alone.
#   + Repair tasks that pass update labels; without this, labels could
#     become out-of-date simply because a DUT is idle.
#
# Locked hosts are skipped because they can't run jobs and because we
# want them to show up as suspicious anyway.
 
 
cd $(dirname $0)/..
 
# Gather all the hosts under supervision of the lab techs.
# Basically, that's any host in any managed pool.
 
GET_HOSTS='
  /pool:(suites|bvt|cq|continuous|cts|arc-presubmit|crosperf|performance)/ {
    print $1
  }
'
HOSTS=( $(cli/atest host list --unlocked | awk "$GET_HOSTS") )
 
 
# Go through the gathered hosts, and use dut_status to find the
# ones with unknown state (anything without a positive "OK" or
# "NO" diagnosis).
 
NEED_CHECK='
  /OK/ || /NO/ { next }
  /^chromeos/ { print $1 }
'
CHECK=( $(site_utils/dut_status.py -d 19 "${HOSTS[@]}" | awk "$NEED_CHECK") )
 
contrib/repair_hosts "${CHECK[@]}"