[worker] fix starting pingAlive thread once#10428
Conversation
|
just got an exception that looks not great. converting to draft |
| self.consumer_threads[push_queue].start() | ||
| # Listen for webhook message | ||
| if connector["config"].get("listen_callback_uri") is not None: | ||
| if "connector_user" in connector and connector["config"].get("listen_callback_uri") is not None: |
There was a problem hiding this comment.
did not test much this part but I ran into issues with external import connectors. looking at the code, it seems to be wrong to use listen_callback_uri as a condition to create an ApiConsumer because it is always set up by the connector helper (https://github.com/OpenCTI-Platform/client-python/blob/073609f05b968455e9ecb905612bdedb523c14dd/pycti/connector/opencti_connector_helper.py#L1105)
There was a problem hiding this comment.
resolving with OpenCTI-Platform/client-python#867
the exception was due to a control-C/sigterm & introduced earlier with the addition of the threadpool. TODO:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #10428 +/- ##
=======================================
Coverage 65.44% 65.44%
=======================================
Files 672 672
Lines 67031 67031
Branches 7347 7354 +7
=======================================
Hits 43870 43870
Misses 23161 23161 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
sibbling PR in pycti: OpenCTI-Platform/client-python#867 |
1b9b0d7 to
6f9da17
Compare
|
@sbocahu I was about to test locally but there is a conflict with current master, I'm not sure on how to resolve it. Could you rebase and manage the conflit ? |
80d278c to
97b3c43
Compare
|
done |
aHenryJard
left a comment
There was a problem hiding this comment.
Tested locally, all good to me. I used some connectors, and also stopped opencti for a while to see if the worker is correctly taking back work when opencti is up again and it's all good.
|
Please dont merge until my review |
richard-julien
left a comment
There was a problem hiding this comment.
Need review and change
97b3c43 to
81806b2
Compare
b151979 to
70dfcb6
Compare
Proposed changes
Checklist
Further comments
Before this change, a worker would create a pingAlive thread per rabbitmq queue, which is useless & consumes resources.
Also, on exceptions (eg. a message which is not valid json), the consuption would fail and restart, creating a new pingAlive thread. Exceptions during ingestion would then lead to an ever increasing number of these pingAlive threads.
A comment suggested graceful stop was handled but it was incomplete/incorrect.