Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] endpoint to stop/kill a running job #225

Closed
1 of 3 tasks
eshaan7 opened this issue Oct 13, 2020 · 5 comments · Fixed by #339
Closed
1 of 3 tasks

[API] endpoint to stop/kill a running job #225

eshaan7 opened this issue Oct 13, 2020 · 5 comments · Fixed by #339
Assignees

Comments

@eshaan7
Copy link
Member

eshaan7 commented Oct 13, 2020

In this case it would be nice to have a button - kill job or stop job.

Originally posted by @WhiteHatMR in https://github.com/intelowlproject/IntelOwl/issue_comments/707807962

We could add a kill button to the job (analysis) result page. This button when invoked should stop all ongoing celery tasks (i.e. all running analyzers) for the particular job. The status of such job should then be marked failed or killed.

This sounds easy on paper, but would require much changes:

  • To stop an ongoing celery task, we can send a control signal (TERM) (ref.) but it requires the ID for the particular task. So need a way to keep track of all celery task IDs for a particular job.
  • An endpoint /api/kill_analysis/{job_id} with appropriate permission enforcing i.e. If X created the job then only the admin and X should be allowed to kill it.

Checklist:

  • API endpoint
  • Button in frontend (IntelOwl-ng)
  • member function and CLI command in pyintelowl.
@eshaan7
Copy link
Member Author

eshaan7 commented Jan 20, 2021

So need a way to keep track of all celery task IDs for a particular job.

Could use django's low level cache API to store the task IDs (or just the celery task object if it's serializable?) for a particular job or set our own task_id.

@sp35
Copy link
Member

sp35 commented Feb 13, 2021

Hi, I would like to work on this issue.

eshaan7 pushed a commit that referenced this issue Feb 15, 2021
Signed-off-by: Shubham Pandey <shubhampcpandey13@gmail.com>
@eshaan7
Copy link
Member Author

eshaan7 commented Feb 15, 2021

The API endpoint has been added, thanks to @sp35. Now we need to add support for this to pyintelowl as well as IntelOwl-ng.

@eshaan7
Copy link
Member Author

eshaan7 commented Feb 15, 2021

We could add a kill button to the job (analysis) result page. This button when invoked should stop all ongoing celery tasks (i.e. all running analyzers) for the particular job. The status of such job should then be marked failed or killed.

Tracking in IntelOwl-ng as intelowlproject/IntelOwl-ng#70.

@eshaan7
Copy link
Member Author

eshaan7 commented Feb 15, 2021

New member function def kill_running_job(job_id: int) -> bool in pyintelowl.

Tracking in pyintelowl as intelowlproject/pyintelowl#67.

EDIT: also corresponding CLI command.

@eshaan7 eshaan7 changed the title A button/endpoint to stop/kill an ongoing job/analysis [API] endpoint to stop/kill a running job Feb 15, 2021
@eshaan7 eshaan7 closed this as completed Feb 15, 2021
@eshaan7 eshaan7 linked a pull request Feb 16, 2021 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants