@@ -28,15 +28,19 @@ MOJO_CONNECT_TIMEOUT=${MOJO_CONNECT_TIMEOUT:-30}
2828client_args=(api --header ' User-Agent: openqa-label-known-issues (https://github.com/os-autoinst/scripts)' --host " $host_url " --retries=" $retries " )
2929
3030out=" ${REPORT_FILE:- $(mktemp -t openqa-label-known-issues--output-XXXX)} "
31- declare timeago
3231trap ' error-handler "$LINENO"' ERR
33- trap ' test "$KEEP_REPORT_FILE" == "1" || rm "$out"' EXIT
34- trap ' test "$KEEP_JOB_HTML_FILE" == "1" || rm "$html_out"' EXIT
32+ trap ' _cleanup' EXIT
33+
34+ _cleanup () {
35+ test " $KEEP_REPORT_FILE " == " 1" || rm " $out "
36+ test " $KEEP_JOB_HTML_FILE " == " 1" || rm -f " $html_out "
37+ }
3538
3639echoerr () { echo " $@ " >&2 ; }
3740
3841handle_unreachable () {
3942 local testurl=$1
43+ local timeago
4044 html_out=${JOB_HTML_FILE:- $(mktemp -t openqa-label-known-issues--job-details-XXXX)}
4145 if ! curl " ${curl_args[@]} " -s --head " $testurl " -o /dev/null; then
4246 # the page might be gone, try the scheme+host we configured (might be different one though)
@@ -58,12 +62,20 @@ handle_unreachable() {
5862 curl " ${curl_args[@]} " " $testurl "
5963 exit 2
6064 fi
61- timeago=$( grep timeago " $html_out " | hxselect -s ' \n' -c ' .timeago::attr(title)' )
6265
6366 if hxnormalize -x " ${html_out} " | hxselect -s ' \n' -c ' .links_a .resborder' | grep -qPzo ' (?s)Gru job failed.*connection error.*Inactivity timeout' ; then
6467 " ${client_call[@]} " -X POST jobs/" $id " /comments text=' poo#62456 test incompletes after failing in GRU download task on "Inactivity timeout" with no logs'
6568 " ${client_call[@]} " -X POST jobs/" $id " /restart
66- return
69+ return 1
70+ fi
71+
72+ # Checking timestamp given by job details page
73+ timeago=$( grep timeago " $html_out " | hxselect -s ' \n' -c ' .timeago::attr(title)' )
74+ if [[ $( date -uIs -d ' -14days' ) > $timeago ]]; then
75+ # if the page is there but not even an autoinst-log.txt exists
76+ # then the job might be too old and logs are already deleted.
77+ echoerr " '$testurl ' job#${id} without autoinst-log.txt older than 14 days. Do not label"
78+ return 1
6779 fi
6880}
6981
@@ -138,16 +150,9 @@ investigate_issue() {
138150 echo " $reason " >> " $out "
139151 if [[ " $curl_output " != " 200" ]] && [[ " $curl_output " != " 301" ]]; then
140152 # if we can not even access the page it is something more critical
141- handle_unreachable " $testurl " " $out " || return
153+ handle_unreachable " $testurl " " $out " || return 0
142154
143155 [[ $curl_output != 404 ]] && return
144- # Checking timestamp given by job details page
145- if [[ $( date -uIs -d ' -14days' ) > $timeago ]]; then
146- # if the page is there but not even an autoinst-log.txt exists
147- # then the job might be too old and logs are already deleted.
148- echoerr " '$testurl ' job#${id} without autoinst-log.txt older than 14 days. Do not label"
149- return
150- fi
151156 # not unreachable, no log, no reason, not too old
152157 if [[ -z $reason ]] || [[ $reason = null ]]; then
153158 echoerr " '$testurl ' does not have autoinst-log.txt or reason, cannot label"
0 commit comments