CLI commands should exit-fail if no jobs scheduled
ClosedPublic

Authored by adamwill on Aug 28 2015, 12:29 AM.

Details

Summary

Have the backing functions always raise TriggerExceptions if
no jobs could be scheduled, and have the CLI command functions
just quit (with exit code 1) immediately when this happens.
I don't see any value to logging the errors and continuing to
run, nothing useful is going to happen with no jobs.

This allows us to have the 'current' cronjob run the compose
report: we just have it do:

openqa_trigger.py current && check-compose

then it won't generate a compose report every time it runs, but
only when the current compose changed and some jobs ran.

Test Plan

Well, just make sure things quit or run as intended,
I guess.

Diff Detail

Repository
rOPENQA fedora_openqa
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
adamwill retitled this revision from to CLI commands should exit-fail if no jobs scheduled.Aug 28 2015, 12:29 AM
adamwill updated this object.
adamwill edited the test plan for this revision. (Show Details)
adamwill added reviewers: jskladan, garretraziel.
garretraziel requested changes to this revision.Aug 28 2015, 7:57 AM

This looks good to me overall, but it actually doesn't work, because sys.exit doesn't do string formatting (as opposed to logging), you have to use .format or %.

Additionally, I would argue that we still want to have "No jobs run" shown in log, so what about logging this message with log and then calling sys.exit(1)?

tools/openqa_trigger/openqa_trigger.py
216

This doesn't work on my machine, I had to use string format.

267–268

See above.

This revision now requires changes to proceed.Aug 28 2015, 7:57 AM

This looks good to me overall, but it actually doesn't work, because sys.exit doesn't do string formatting (as opposed to logging), you have to use .format or %.

Additionally, I would argue that we still want to have "No jobs run" shown in log, so what about logging this message with log and then calling sys.exit(1)?

D'oh, you're right - guess who didn't bother to test those bits...

adamwill updated this revision to Diff 1413.Aug 28 2015, 8:02 AM

log error then exit, as suggested by garretraziel

garretraziel accepted this revision.Aug 28 2015, 12:19 PM

Yup, looks OK.

This revision is now accepted and ready to land.Aug 28 2015, 12:19 PM
This revision was automatically updated to reflect the committed changes.