ceph / teuthology-api

A REST API to execute teuthology commands.
MIT License
2 stars 10 forks source link

suite: handle cancelled requests #26

Open VallariAg opened 1 year ago

VallariAg commented 1 year ago

Current behaviour: When a request is sent to /suite and the teuthology-suite command is being executed, then if the client request is cancelled (due to timeout or any other reason), the command continues to schedule.

Expected behaviour: If the request is cancelled, the scheduling command should also be cancelled/stopped.

dikwickley commented 1 year ago

hi @VallariAg i would like to work on this issue.

dikwickley commented 1 year ago

The main issue here is there is no way to know at the FastAPI server if the client has disconnected. After going through https://github.com/tiangolo/fastapi/discussions/8805 and https://github.com/tiangolo/fastapi/discussions/8699 i found this https://github.com/RedRoserade/fastapi-disconnect-example/blob/main/app.py.

A simple example that uses polling to check if the user has cancelled the request or not.

This works pretty well with only caveat that we would need to use uvicorn instead of gunicorn. What do you think @VallariAg

VallariAg commented 1 year ago

Hey @dikwickley, this issue would need more discussions before we can plan on working on this. We might make the long-running functions execute asynchronously which should also handle this issue.

dikwickley commented 1 year ago

@VallariAg makes sense. I had created a PR that does just that #29