Conversation
Test results0 tests 0 ✅ 0s ⏱️ Results for commit beef6b8. ♻️ This comment has been updated with latest results. |
7696117 to
3f87649
Compare
There was a problem hiding this comment.
So, in short, this appears to refactor the existing in-process notification handler by reframing it as a django-tasks task with the ImmediateBackend.
Lots of questions:
-
I assume the end goal is to replace the
ImmediateBackendwithDatabaseBackendand adb_workermanagement command? (Or perhaps our own custom backend?) -
Why is it a good idea to split 'check for notifications' and 'send notifications' into separate tasks?
-
Have you figured out how to transition from
django-tasksto Django 6? -
You mentioned something in IRL that I interpreted as "the db_worker uses database polling". This is why I became averse to the django-q2-based PoC. Could we add NOTIFY/LISTEN support to the db_worker or would we have to write our own? I do realize that a NOTIFY/LISTEN-based mechanism would be PostgreSQL specific - but then again, at what point are we not tied to PostgreSQL already?
Nevertheless, the refactor so far looks quite neat and clean, and I'm glad to see we can eventually accomplish this without the need for a bunch of 3rd party libraries or components :)
Yes. We ought to document using DatabaseBackend.
Because
Eight-ball says: too soon to say. RealOrangeOne/django-tasks#204
I thought your main beef with django-q2 was that it used pickle? django-tasks slings around json-blobs, to the despair of people who very much prefer pickle. https://github.com/RealOrangeOne/django-tasks/discussions/85 I don't see a problem with poll, it works very well if argus sees as much traffic as I fear it might in the future. How well would NOTIFY/SUBSCRIBE handle the mist spam, lots of incidents at the same second?
|
Goes on to describe polling with "FOR UPDATE SKIP LOCKED", which is exactly what django-tasks' database backend does... |
3f050e8 to
0251848
Compare
|
0251848 to
933c407
Compare
|
Switching to django 6.0 is seddable and would entail:
It wouldn't change anything in the database, that won't happen until/if the database backend is included with django. What would need at least to happen then is:
|
aleksfl
left a comment
There was a problem hiding this comment.
Seems to run as it should, although I am still testing how to send the notifications properly. Some minor comments but nothing important. Code looks good in general.
|
|
||
| postgres: | ||
| image: "postgres:14" | ||
| image: "postgres:15" |
There was a problem hiding this comment.
I'm assuming this is a necessary change? Might be worth noting on the PR for clarity.
lunkwill42
left a comment
There was a problem hiding this comment.
Ok, so I gave this a once-over with manual testing with the database backend, and it appears to work ok, but I did find three issues: Two related to this PR and also a more troubling one, that appears also on main.
- It seems that this PR does not adhere to the
SEND_NOTIFICATIONSsetting. It sends notifications regardless. Did I miss something? - Completed tasks are left in the queue and litter the database. I can no longer find the
django-tasksdocumentation online, apparently because it subsumed into Django. The README mentions pruning old tasks from the database: https://github.com/RealOrangeOne/django-tasks?tab=readme-ov-file#pruning-old-tasks . This is not mentioned in the Django 6 docs, as far as I can see, but the problem is still there. We should perhaps document how users should set up a cron job to prune old tasks from the queue. - I could not get Argus to send notifications when I made other incident changes (i.e. acknowledging, closing etc.), so I switched back to
mainand observed the same behavior there. This is troubling. Any idea what has changed, when? Am I doing something wrong?
933c407 to
1c70246
Compare
.. using the ImmediateBackend, so no delays.
78284f2 to
beef6b8
Compare
|



Scope and purpose
Might eventually close #166, #359, #400.
Use django-tasks to send notifications instead of a background process. Currently uses django signals to enqueue tasks on Event create. With the database backend we could use a trigger to add a task on database save of an event!
Has one task to check whether to send notifications and another to actually send the notification.
Test by for instance having a filter that triggers on argus as source 24/7 and sends an email. Turn notifications on (
SEND_NOTIFICATIONS=Truein settings or use the environment variableSEND_NOTIFICATIONS=yes) and use a dummy email backend (EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" in settings).This pull request
Contributor Checklist
Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to Argus can be found in the
Development docs.
[ ] If this results in changes in the UI: Added screenshots of the before and after