blob: 3d329b395476e8a9bfb2c4034533a4514a190943 [file] [log] [blame]
J. Richard Barnette254e80d2015-04-20 15:07:51 -07001# By default, we're invoked without arguments. This is how the cron
2# job does it, and means we should generate output and mail it to
3# the default mail alias.
4#
5# Invoking with arguments is for testing: It allows running through
6# the full logic and output generation, without spamming the alert
7# aliases.
8
9OPTIONS=""
10if [ $# -eq 0 ]; then
11 # TODO(jrbarnette): Really, this feels like a hack. The cron job
12 # that invokes the inventory scripts is installed and enabled on
13 # both a primary and backup server, meaning the e-mail will be
14 # generated twice. We don't want that, so unless this is the
15 # primary server, quash this job.
16 if ! cli/atest server list $(hostname) 2>&1 |
17 grep -q '^Status *: *primary'; then
18 exit 0
19 fi
20
21 POOL_INTEREST=(
22 chromeos-infra-eng@grotations.appspotmail.com
Aviv Keshet9a27f192017-04-14 11:06:02 -070023 chromeos-build-alerts+dut-pool@google.com
J. Richard Barnette254e80d2015-04-20 15:07:51 -070024 )
Richard Barnette5de01eb2017-12-15 09:53:42 -080025 MODEL_INTEREST=(
J. Richard Barnettee78a7002015-05-27 07:27:24 -070026 englab-sys-cros@google.com
Aviv Keshet9a27f192017-04-14 11:06:02 -070027 chromeos-build-alerts+dut-pool@google.com
J. Richard Barnette254e80d2015-04-20 15:07:51 -070028 )
29else
Richard Barnette5de01eb2017-12-15 09:53:42 -080030 MODEL_INTEREST=( "$@" )
J. Richard Barnette254e80d2015-04-20 15:07:51 -070031 POOL_INTEREST=( "$@" )
Richard Barnette45ac0332017-12-18 16:27:13 -080032 OPTIONS=--debug
J. Richard Barnette254e80d2015-04-20 15:07:51 -070033fi
34
Richard Barnette45ac0332017-12-18 16:27:13 -080035# Options to be used for different script invocations. Inventory
36# runs are relatively expensive, so operations that happen rarely
37# also bundle operations that happen more frequently.
Richard Barnette1ca30e62018-04-09 16:45:58 -070038# + UNTESTABLE_DETECT happens with every run. It looks for
39# and reports DUTs that for never run tests even though their
40# status indicates that they should.
Richard Barnette5de01eb2017-12-15 09:53:42 -080041# + MODEL_NOTIFY happens less often. This adds a full model
Richard Barnette45ac0332017-12-18 16:27:13 -080042# inventory count to REPAIR_LOOP_DETECT.
43# + POOL_NOTIFY happens least often. It adds per-pool inventory
44# counts, as well as individual DUT repair recommendations to
Richard Barnette5de01eb2017-12-15 09:53:42 -080045# MODEL_NOTIFY.
Richard Barnette45ac0332017-12-18 16:27:13 -080046
Richard Barnette1ca30e62018-04-09 16:45:58 -070047UNTESTABLE_DETECT=( --report-untestable )
Richard Barnette45ac0332017-12-18 16:27:13 -080048
Richard Barnette5de01eb2017-12-15 09:53:42 -080049MODEL_NOTIFY=(
Richard Barnette1ca30e62018-04-09 16:45:58 -070050 "${UNTESTABLE_DETECT[@]}"
Richard Barnette5de01eb2017-12-15 09:53:42 -080051 --model-notify $(echo "${MODEL_INTEREST[@]}" | sed 's/ /,/g')
J. Richard Barnette254e80d2015-04-20 15:07:51 -070052)
Richard Barnette45ac0332017-12-18 16:27:13 -080053
J. Richard Barnette254e80d2015-04-20 15:07:51 -070054POOL_NOTIFY=(
Richard Barnette5de01eb2017-12-15 09:53:42 -080055 "${MODEL_NOTIFY[@]}"
Richard Barnette3d08dc82017-02-16 15:27:39 -080056 --recommend=40
Richard Barnette45ac0332017-12-18 16:27:13 -080057 --pool-notify $(echo "${POOL_INTEREST[@]}" | sed 's/ /,/g')
J. Richard Barnette254e80d2015-04-20 15:07:51 -070058)