Skip to content

Commit ccb3851

Browse files
authored
Add some comments for recent code (#22725)
When using the main branch, I found that some changed code didn't have comments. This PR adds some comments.
1 parent 368d436 commit ccb3851

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

models/dbfs/dbfs.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,35 @@ import (
1010
"code.gitea.io/gitea/models/db"
1111
)
1212

13+
/*
14+
The reasons behind the DBFS (database-filesystem) package:
15+
When a Gitea action is running, the Gitea action server should collect and store all the logs.
16+
17+
The requirements are:
18+
* The running logs must be stored across the cluster if the Gitea servers are deployed as a cluster.
19+
* The logs will be archived to Object Storage (S3/MinIO, etc.) after a period of time.
20+
* The Gitea action UI should be able to render the running logs and the archived logs.
21+
22+
Some possible solutions for the running logs:
23+
* [Not ideal] Using local temp file: it can not be shared across the cluster.
24+
* [Not ideal] Using shared file in the filesystem of git repository: although at the moment, the Gitea cluster's
25+
git repositories must be stored in a shared filesystem, in the future, Gitea may need a dedicated Git Service Server
26+
to decouple the shared filesystem. Then the action logs will become a blocker.
27+
* [Not ideal] Record the logs in a database table line by line: it has a couple of problems:
28+
- It's difficult to make multiple increasing sequence (log line number) for different databases.
29+
- The database table will have a lot of rows and be affected by the big-table performance problem.
30+
- It's difficult to load logs by using the same interface as other storages.
31+
- It's difficult to calculate the size of the logs.
32+
33+
The DBFS solution:
34+
* It can be used in a cluster.
35+
* It can share the same interface (Read/Write/Seek) as other storages.
36+
* It's very friendly to database because it only needs to store much fewer rows than the log-line solution.
37+
* In the future, when Gitea action needs to limit the log size (other CI/CD services also do so), it's easier to calculate the log file size.
38+
* Even sometimes the UI needs to render the tailing lines, the tailing lines can be found be counting the "\n" from the end of the file by seek.
39+
The seeking and finding is not the fastest way, but it's still acceptable and won't affect the performance too much.
40+
*/
41+
1342
type dbfsMeta struct {
1443
ID int64 `xorm:"pk autoincr"`
1544
FullPath string `xorm:"VARCHAR(500) UNIQUE NOT NULL"`

modules/httpcache/httpcache.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
func AddCacheControlToHeader(h http.Header, maxAge time.Duration, additionalDirectives ...string) {
2020
directives := make([]string, 0, 2+len(additionalDirectives))
2121

22+
// "max-age=0 + must-revalidate" (aka "no-cache") is preferred instead of "no-store"
23+
// because browsers may restore some input fields after navigate-back / reload a page.
2224
if setting.IsProd {
2325
if maxAge == 0 {
2426
directives = append(directives, "max-age=0", "private", "must-revalidate")

tests/mysql.ini.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
126126
ENABLED = true
127127

128128
[email.incoming]
129+
; temporarily disabled because the incoming mail tests are flaky due to the IMAP server (during integration tests) couldn't be not ready in time sometimes.
129130
ENABLED = false
130131
HOST = smtpimap
131132
PORT = 993

0 commit comments

Comments
 (0)