Project

General

Profile

Feature #8144

Add a purge mechanism for tasks

Added by Romain Vrignaud almost 6 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

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 ?

Thoughts ?

Associated revisions

Revision fb88f077 (diff)
Added by Ivan Necas over 5 years ago

Fixes #8144 - cleanup mechanism for tasks

This adds a rake task for cleaning tasks based on filter and age.
Example:

  1. delete all the tasks of
    rake foreman_tasks:cleanup FILTER='label = "Actions::Foreman::Host::ImportFacts"'
  1. delete all tasks older than 30 days
    rake foreman_tasks:cleanup AFTER=30d
  1. delete all tasks that have the auto-cleanup specified in code or settings
    rake foreman_tasks:cleanup

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
that with:

rake foreman_tasks:cleanup:config

Revision 5254093b
Added by Ivan Necas about 5 years ago

Merge pull request #100 from iNecas/tasks-cleanup

Fixes #8144 - cleanup mechanism for tasks

History

#1 Updated by Ivan Necas almost 6 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.

#2 Updated by Ivan Necas over 5 years ago

  • Status changed from New to Assigned

#3 Updated by Ivan Necas over 5 years ago

  • Assignee set to Ivan Necas

#4 Updated by The Foreman Bot over 5 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman-tasks/pull/100 added
  • Pull request deleted ()

#5 Updated by Ivan Necas over 5 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?

#6 Updated by Marek Hulán over 5 years ago

Visually the PR looks very nice, I didn't tested though. One thing that I don't see is the export feature (point 3. in your comment) but we may open separate issue for this as we may think of adding also a way to reimport.

#7 Updated by Ivan Necas about 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF