open-contracting / deploy

Deployment configuration and scripts
https://ocdsdeploy.readthedocs.io/en/latest/
Apache License 2.0
2 stars 3 forks source link

Cove-ocds: /tmp Disk Space management #359

Closed ghost closed 2 years ago

ghost commented 2 years ago

Django is not clearing temporary files which has lead to disk space running out. See: ls -lh /tmp/*.upload*

Possible solutions:

This issue may effect other Django applications so they need checking.

jpmckinney commented 2 years ago

Only this application receives a significant number of uploads, so I think it's limited to this and the cove-oc4ids server.

jpmckinney commented 2 years ago

I read https://docs.djangoproject.com/en/4.0/topics/http/file-uploads/#upload-handlers but not much there or on linked pages.

It seems like Django should be deleting the temporary files once they are closed: https://github.com/django/django/blob/main/django/core/files/temp.py

I'll check the CoVE code to see if it's leaving files unclosed (e.g. by leaking file handles).

jpmckinney commented 2 years ago

This comment suggests that the files need to be manually closed: https://stackoverflow.com/a/23657999

However, this comment explains that they are closed when the request is closed: https://stackoverflow.com/a/62357029:

So a few possibilities:

Anyway, that's as much time as I have. We can maybe use tmpreaper or a simple cron job.

FYI @Bjwebb