Add a purge mechanism for tasks
I'm currently using foreman-tasks to process facts (from foreman_chef) uploading (and hopefully reports one day).
It creates a lot of tasks per hour and I don't see any point to keep in db all that tasks.
IMHO it would be very useful to have a purge mechanism : it may have to run as a cron task ?
Fixes #8144 - cleanup mechanism for tasks
This adds a rake task for cleaning tasks based on filter and age.
- delete all the tasks of
rake foreman_tasks:cleanup FILTER='label = "Actions::Foreman::Host::ImportFacts"'
- delete all tasks older than 30 days
rake foreman_tasks:cleanup AFTER=30d
- delete all tasks that have the auto-cleanup specified in code or settings
By default, it only touches tasks in stopped state, this behaviour can be
customized by setting the `STATES` parameter.
To see the current configuration for the auto-cleanup, one can see
#1 Updated by Ivan Necas almost 7 years ago
Thank you for reporting. I agree we need a purge mechanism to be there. Since the foreman-tasks
can have an auditing value as well (especially once they will get wider usage - and they don't
have to be used only for async tasks, but for audit as well), I would like to make it more
configurable. Also, some task info are more valuable than the others. What about this suggestion:
1. There are two purge mechanisms: reduce (would keep just subset of the original data, for audit purposes) and delete
2. It's possible to export the data to disk for archiving.
3. it would be possible to configure a combination of [priority, scoped-search filter + age, purge mechanism, export (true, false)]
and a task (either a rake task, or some foreman-task itself) would periodically clean the data.
#5 Updated by Ivan Necas over 6 years ago
This adds a rake task for cleaning tasks based on filter and age. Example:
# delete all the tasks of rake foreman_tasks:clean FILTER='label = "Actions::Foreman::Host::ImportFacts"' # delete all tasks older than 30 days rake foreman_tasks:clean BEFORE=2592000 # delete all tasks older than 10 days (the default BEFORE value) rake foreman_tasks:clean
It doesn't touch tasks that are in other than running or paused state. Opinions?