novacode-nl / odoo-celery

Odoo & Celery integration
GNU Lesser General Public License v3.0
42 stars 44 forks source link

[UPD] Configurable celery queues added. #20

Closed antonioburic closed 4 years ago

antonioburic commented 4 years ago

Addition of configurable celery queues for types of tasks (configured in task settings as a one2many):

Adds a new menu in Celery -> Settings -> Queues. The kanban view adds some additional stats on the tasks in each queue: image

Queues tab on the task settings form: image

bobslee commented 4 years ago

@antonioburic I didn't notice any improvements to move Pending tasks to a different queue? Is that still in consideration/roadmap or would this be too tricky to implement?

antonioburic commented 4 years ago

@antonioburic I didn't notice any improvements to move Pending tasks to a different queue? Is that still in consideration/roadmap or would this be too tricky to implement?

@bobslee You're right, great idea to add that as well. ^^ I'm just getting back to this PR now, I'll try to update it today/tomorrow.

antonioburic commented 4 years ago

@bobslee Improvements added, the computed fields containing the queue stats are now retrieved only when displaying the kanban view (using a context value in an action) + SQL significantly improved thanks to your suggestion. :)

Let me know if you have any further ideas that we can improve this on. I haven't added the part about moving Pending tasks to another queue, but will try to address this too. ^^

antonioburic commented 4 years ago

I think if we can add a way to poll celery workers to check if they're active/running at any given time, that would be very useful for monitoring, and we could display this status on the queue kanban view along with stats (+ then we could possibly set up notifications when a worker/queue goes down due to heartbeat issues and other possible reasons). Just a basic idea for now, but if doable, this would be really useful for monitoring, I'll try to research a bit in this direction...

bobslee commented 4 years ago

@bobslee Improvements added, the computed fields containing the queue stats are now retrieved only when displaying the kanban view (using a context value in an action) + SQL significantly improved thanks to your suggestion. :)

Let me know if you have any further ideas that we can improve this on. I haven't added the part about moving Pending tasks to another queue, but will try to address this too. ^^

@antonioburic thanks for the improvements, which look really good! I shall test and merge a.s.a.p. (next days).

bobslee commented 4 years ago

I think if we can add a way to poll celery workers to check if they're active/running at any given time, that would be very useful for monitoring, and we could display this status on the queue kanban view along with stats (+ then we could possibly set up notifications when a worker/queue goes down due to heartbeat issues and other possible reasons). Just a basic idea for now, but if doable, this would be really useful for monitoring, I'll try to research a bit in this direction...

We both have the same ideas @antonioburic :) A few days ago, I already did some research how to really Cancel and Requeue tasks. This involves termination of the running task(s) - hence the Odoo process and task in Celery worker/broker.

These features also need to check whether the tasks are still running and present in the MQ/workers before termination etc. I already did a quick study of the Flower (monitoring) library, which does all kinds of stuff with checking and monitoring. We really get the advantage by studying the Flower library, to address the new features regarding termination and monitoring - which looks rather feasible to me.

bobslee commented 4 years ago

@antonioburic I'm reviewing (testing) this PR. Following are some topics I want to share, please.

1. Celery Queues

1.1 So celery.queue records can be created from the list (tree) view, but not the kanban view? Is there a specific reason?

1.2 On the celery.queue form, there's the Many2many celery.task.setting (computed field) listing. It doesn't get filled with records. Maybe change to Many2many assignment [(6, False, [ids, ...])]?

I suggest to add a notebook/page called "Task Settings" as container for this overview.

1.3 Typo in celery.queue kanban tile Spotted a typo "Succeded in the last 24" => "Succeeded"

1.4 celery.queue kanban shows inactive records Maybe better to hide the inactive celery.queue records in the kanban view?

2. Celery Task Settings

Regarding the new notebook/page "Queues". Could you rename the label of N: to the complete label Use if less then (pending tasks) ? (shown in the Queues tab / settings).

Looking forward to your follow up :) Thanks!

bobslee commented 4 years ago

@antonioburic please mind/change the module version +1. Because I just merged a PR "auto cleanup/vacuum of old tasks" (became version 15).

antonioburic commented 4 years ago

@bobslee PR updated/edited with all the points you mentioned. ^^ So, this should be good to be merged now, I'll just add the port to v12.