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

Clear up old Actions logs #31735

Merged
merged 17 commits into from
Aug 2, 2024
Merged

Conversation

wolfogre
Copy link
Member

@wolfogre wolfogre commented Jul 30, 2024

Part of #24256.

Clear up old action logs to free up storage space.

Users will see a message indicating that the log has been cleared if they view old tasks.

image

Docs: https://gitea.com/gitea/docs/pulls/40

@wolfogre wolfogre added type/feature Completely new functionality. Can only be merged if feature freeze is not active. topic/gitea-actions related to the actions of Gitea labels Jul 30, 2024
@wolfogre wolfogre added this to the 1.23.0 milestone Jul 30, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 30, 2024
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 30, 2024
@github-actions github-actions bot added modifies/translation modifies/go Pull requests that update Go code labels Jul 30, 2024
models/actions/task.go Outdated Show resolved Hide resolved
models/actions/task.go Outdated Show resolved Hide resolved
@silverwind
Copy link
Member

When does this run exactly? Via some cron?

@wolfogre
Copy link
Member Author

wolfogre commented Aug 1, 2024

@silverwind Yes. The spec is @midnight.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 1, 2024
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 1, 2024
@lunny lunny added pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Aug 1, 2024
@lunny lunny enabled auto-merge (squash) August 2, 2024 00:12
@lunny lunny merged commit 687c118 into go-gitea:main Aug 2, 2024
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Aug 2, 2024
zjjhot added a commit to zjjhot/gitea that referenced this pull request Aug 2, 2024
* giteaofficial/main:
  Clear up old Actions logs (go-gitea#31735)
  Fix createElementFromAttrs bug (go-gitea#31751)
  bump vue-bar-graph (go-gitea#31705)
  Use UTC as default timezone when schedule Actions cron tasks (go-gitea#31742)
  Add permission description for API to add repo collaborator (go-gitea#31744)
  Clarify Actions resources ownership (go-gitea#31724)
  Exclude protected branches from recently pushed (go-gitea#31748)
  [skip ci] Updated translations via Crowdin
  Distinguish LFS object errors to ignore missing objects during migration (go-gitea#31702)
wolfogre added a commit that referenced this pull request Aug 9, 2024
Support compression for Actions logs to save storage space and
bandwidth. Inspired by
#24256 (comment)

The biggest challenge is that the compression format should support
[seekable](https://github.com/facebook/zstd/blob/dev/contrib/seekable_format/zstd_seekable_compression_format.md).
So when users are viewing a part of the log lines, Gitea doesn't need to
download the whole compressed file and decompress it.

That means gzip cannot help here. And I did research, there aren't too
many choices, like bgzip and xz, but I think zstd is the most popular
one. It has an implementation in Golang with
[zstd](https://github.com/klauspost/compress/tree/master/zstd) and
[zstd-seekable-format-go](https://github.com/SaveTheRbtz/zstd-seekable-format-go),
and what is better is that it has good compatibility: a seekable format
zstd file can be read by a regular zstd reader.

This PR introduces a new package `zstd` to combine and wrap the two
packages, to provide a unified and easy-to-use API.

And a new setting `LOG_COMPRESSION` is added to the config, although I
don't see any reason why not to use compression, I think's it's a good
idea to keep the default with `none` to be consistent with old versions.

`LOG_COMPRESSION` takes effect for only new log files, it adds `.zst` as
an extension to the file name, so Gitea can determine if it needs
decompression according to the file name when reading. Old files will
keep the format since it's not worth converting them, as they will be
cleared after #31735.

<img width="541" alt="image"
src="https://github.com/user-attachments/assets/e9598764-a4e0-4b68-8c2b-f769265183c9">
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Oct 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code modifies/migrations modifies/translation pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! size/L Denotes a PR that changes 100-499 lines, ignoring generated files. topic/gitea-actions related to the actions of Gitea type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants