About this Contributor Invite:
- Task Area: Coding
- Effort rating: 3/5
- Skills required: Python, pytest, Django Middlware/Views/Templates
Description of the Problem:
When there are too many simultaneous requests to FreedomBox Service (Plinth), or perhaps when the disk I/O is too slow, users see a Database is locked
error. It has been discussed how to handle this and was decided that we will show a simplified error asking for users to retry. But it turns out that this error is misleading and confuses users into believing there is a deeper problem. We want to change what the user sees when there are too many simultaneous requests to FreedomBox Service (Plinth).
What we ask of you:
Handle this error for all requests that user can make. Show a nice message by implementing a Django Middleware. Follow these steps:
- Create a Django Middleware for handling such common errors in middleware.py and call it
CommonErrorMiddleware
. In it handle the errordjango.db.utils.OperationalError
and return response with HTTP 503 status code. This is the correct code when server is unavailable due to load. - Install this middleware in the list of all middlewares used by FreedomBox. It should rank higher than all other middleware but less than Django provided middlewares.
- Customize the error message page shown for 503 HTTP status code by creating 503.html template. In it show the error message “System is possibly under heavy load. Please retry later.”. Be sure to internationalize the message. See other error templates as examples.
- Create a temporary view which just throws the mentioned OperationalError when visited. With this, whenever the temporary view is visited, the error can be seen. Run the application with and without the
--develop
option on the command line and see the change. - Write automated unit test cases for the middleware in test_middleware.py. The tests should cover all branches of the middleware. See tests for other middleware as example.
Link to the issue in GitLab: https://salsa.debian.org/freedombox-team/plinth/issues/1443
How to claim this Contributor Invite :
Do you want to accept this invitation to contribute? If so, follow these steps:
- Comment on this forum post indicating that you would like to claim the invite. This will prevent multiple people from working on the same issue at the same time.
- Register an account with our GitLab instance and begin making your contributions on the GitLab issue page for this task. You can use the comment section of this forum post to ask questions, but the bulk of the development discussion should happen on GitLab.
Resources:
If you need help with this issue, please feel free to ask for it from members of our core team:
- Sunil Mohan Adapa (@sunil): Lead Developer & Code Reviewer
- Joseph Nuthalapati (@njoseph): DevOps Engineer, Developer, & Code Reviewer
- James Valleroy (@jvalleroy) : Release Manager, Developer, & Code Reviewer