copr-be: copr-ping: print OK status, and more info upon failure
This commit is contained in:
parent
73f19b84e3
commit
a0628a6c37
1 changed files with 14 additions and 4 deletions
|
@ -46,7 +46,7 @@ def error(context, msg, *args):
|
||||||
set_status(context, EXIT_CRITICAL)
|
set_status(context, EXIT_CRITICAL)
|
||||||
|
|
||||||
|
|
||||||
def _main(ctx):
|
def _main(context):
|
||||||
last_lines = queue.Queue()
|
last_lines = queue.Queue()
|
||||||
|
|
||||||
with open(FILE) as file:
|
with open(FILE) as file:
|
||||||
|
@ -56,12 +56,16 @@ def _main(ctx):
|
||||||
if len(last_lines.queue) > TAKE_LAST_N_ATTEMPTS:
|
if len(last_lines.queue) > TAKE_LAST_N_ATTEMPTS:
|
||||||
last_lines.get()
|
last_lines.get()
|
||||||
|
|
||||||
|
builds_checked = 0
|
||||||
while last_lines.queue:
|
while last_lines.queue:
|
||||||
|
builds_checked += 0
|
||||||
|
|
||||||
line = last_lines.get()
|
line = last_lines.get()
|
||||||
values = {
|
values = {
|
||||||
"start": None,
|
"start": None,
|
||||||
"stop": None,
|
"stop": None,
|
||||||
"exit_status": -1,
|
"exit_status": -1,
|
||||||
|
"build_id": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
for value in line.split():
|
for value in line.split():
|
||||||
|
@ -76,12 +80,18 @@ def _main(ctx):
|
||||||
stop = int(values["stop"])
|
stop = int(values["stop"])
|
||||||
took = stop - start
|
took = stop - start
|
||||||
if took > ERR_TIME:
|
if took > ERR_TIME:
|
||||||
error(ctx, "Attempt to build took %ss (allowed %s)", took, WARN_TIME)
|
error(context, "Attempt to build took %ss (allowed %s)", took, WARN_TIME)
|
||||||
elif took > WARN_TIME:
|
elif took > WARN_TIME:
|
||||||
warning(ctx, "Attempt to build took %ss (allowed %s)", took, WARN_TIME)
|
warning(context, "Attempt to build took %ss (allowed %s)", took, WARN_TIME)
|
||||||
|
|
||||||
if int(values["exit_status"]) != 0:
|
if int(values["exit_status"]) != 0:
|
||||||
error(ctx, "Exit status is non-zero: %s", values["exit_status"])
|
error(context, "Exit status is %s (non-zero) for build ID %s",
|
||||||
|
values["exit_status"], values["build_id"])
|
||||||
|
|
||||||
|
if context.status == EXIT_OK:
|
||||||
|
LOG.info("Last %s attempts to build copr-ping succeeded!",
|
||||||
|
builds_checked)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
ctx = Context()
|
ctx = Context()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue