-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixes #38956 - Add cron rake tasks for recurring jobs #10784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Also the failure looks unrelated to the changes |
Yepp, that's a regression in facterdb |
|
The tests were fixed in #10794 -- if you rebase CI should turn green. I think |
f1d3526 to
46d202e
Compare
46d202e to
7512c2f
Compare
fair, working on it :/ |
7512c2f to
569dad9
Compare
569dad9 to
1a8978d
Compare
|
This needs a redmine, and the test setup fixed, but other than that it looks good! Thanks! |
1a8978d to
58f2f81
Compare
@evgeni seems like redmine is not accessible atm |
Fixed it now. |
58f2f81 to
97b3515
Compare
c600fe2 to
43d493c
Compare
43d493c to
dd637c2
Compare
|
@evgeni i see that db fixture error is unrelated to this fix, and rest is working fine now. |
dd637c2 to
31c5350
Compare
|
@evgeni sorry, i forgot looking at this PR earlier, so missed the comment, but thanks, updated now! |
63be2cf to
a097f83
Compare
a097f83 to
ee3ac5d
Compare
Introduce `Foreman::Cron` with a hard-coded mapping from hourly/daily/weekly/monthly to existing rake tasks, and add `cron:hourly`, `cron:daily`, `cron:weekly` and `cron:monthly` rake tasks. These serve as generic entrypoints for scheduling (e.g. systemd timers in foremanctl) instead of wiring individual tasks. Allow plugins to register extra tasks in Foreman::Cron Fail cron:* rake tasks when a job fails Refine Foreman::Cron task Add unit tests for Foreman::Cron unified registry add section on scheduling recurring plugin tasks
ee3ac5d to
5ca5a66
Compare
| Foreman::Cron.register(:daily, 'reports:daily') | ||
| Foreman::Cron.register(:daily, 'db:sessions:clear') | ||
| Foreman::Cron.register(:daily, 'reports:expire') | ||
| Foreman::Cron.register(:daily, 'audits:expire') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When testing this, I realized that the audits:expire task calls exit here:
Lines 69 to 70 in d64ee4e
| puts "The interval for keeping the Audits is not defined in the settings, exiting..." | |
| exit 0 |
Which will abort the whole rake run and skip any follow up tasks, while exiting 0, so no error reporting happens.
I don't think we need to fix that in this PR, but something we should address before going live with this new framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's right, thanks for pointing this out! but yeah let's keep this PR focused for wiring up the cron framework work we did, i'll follow up on another PR for refactor of both reports:* and audits:expire
| Foreman::Cron.register(:daily, 'reports:expire') | ||
| Foreman::Cron.register(:daily, 'audits:expire') | ||
|
|
||
| Foreman::Cron.register(:weekly, 'reports:weekly') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reports:* similarly uses exit, but it seems at least the default config is fine as it did not abort for me.
foreman/lib/tasks/reports.rake
Lines 83 to 84 in d64ee4e
| $stdout.puts "Unable to find puppet environment=#{env}" | |
| exit 1 |
foreman/lib/tasks/reports.rake
Lines 92 to 93 in d64ee4e
| $stdout.puts "invalid fact #{ENV['fact']}" | |
| exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack!
shubhamsg199
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, Tested and works as expected.
Introduce
Foreman::Cronwith a hard-coded mapping fromhourly/daily/weekly/monthlyto existing rake tasks, and addcron:hourly,cron:daily,cron:weeklyandcron:monthlyrake tasks.These serve as generic entrypoints for scheduling (e.g. systemd timers in foremanctl) instead of wiring individual tasks.
Related to: theforeman/foremanctl#288 (review)