-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Gitea leaves large uploads in /tmp #19595
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
Comments
I haven't looked into the problem. Now I can tell some information:
|
I have a feeling that maybe this problem is upstream related .... Or .... Gitea does something wrong .... |
As noted in that ticket, perhaps we aren't using https://pkg.go.dev/mime/multipart#Form.RemoveAll |
It should be called by Golang's http framework automatically. Not sure why it doesnt' work correctly. in func (w *response) finishRequest() {
.....
if w.req.MultipartForm != nil {
w.req.MultipartForm.RemoveAll()
}
} |
I think I find the possible root case. Gitea's Just a guess. |
Just to be precise: I could reproduce the issue with a file of exactly 31457280 bytes, which is less than either 32 MB or 32 MiB. Not sure if this is really relevant here. |
Could you show your |
I had Swagger generate the curl -X 'POST' 'https://$domain/api/v1/repos/$user/$repo/releases/$id/assets?token=$api_token' -H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F 'attachment=@$file' The release I uploaded to was manually created using Gitea's GUI. And here's how I generated my test file: dd if=/dev/zero of=$file bs=1024 count=30 |
OK, everything is clear. My fix works as expected. No more temp files in The answer to if err := ctx.Req.ParseMultipartForm(setting.Attachment.MaxSize << 20); err != nil && !strings.Contains(err.Error(), "EOF") So if your file exceeds |
Description
We use Gitea with Drone. One of our CD jobs builds a large binary and uploads it to Gitea as a release (using Drone's Gitea-Release Plugin). This jobs runs nightly.
Apparently, Gitea stores the upload in
/tmp
and does not remove it from there. Therefore, the server runs out of available disk space after a while.As a workaround, we manually restart Gitea every now and then. Due to Systemd's
PrivateTmp
this also wipes Giteas/tmp
directory.Note: We have
So, I'm not sure, why uploads are stored in
/tmp
at all.After one nightly job the file from the CD job is in Gitea's
/tmp
:To debug the issue, I experimented with uploading attachments to releases via the GUI and the API. In the browser, I'm limited to 20 MB file size and these files did not remain in
/tmp
.When uploading the same 20 MB file with
curl
, it also did not remain in/tmp
.However, I could reproduce the issue by uploading a 30 MB file with
curl
.So, the issue seems to be related to file size.
I can't tell, if only "large" files get written to
/tmp
or all files get written there, but only "small" files are deleted after the upload.I did not investigate, if this issue affects only attachments to releases, or also other kinds of attachments.
It is unclear to me, what exactly the bug is, but I'm fairly certain it is a bug and not a configuration issue on our side.
I think Gitea should probably remove temporary uploads from
/tmp
or store them inTEMP_PATH
instead of/tmp
.If you need any more information or want me to test something, please ask.
We'll update to the latest Gitea release by the end of the week. I'll report back if that changes anything.
Gitea Version
1.16.1
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
2.30.2
Operating System
Debian GNU/Linux 11.2
How are you running Gitea?
Gitea binary is from dl.gitea.io and started via a (custom) Systemd unit:
Database
PostgreSQL
The text was updated successfully, but these errors were encountered: