Skip to content

Commit

Permalink
Add option to skip health check for some repositories
Browse files Browse the repository at this point in the history
Some large git repos (e.g. the Linux Kernel) take an excessively long
time to fsck, and the resulting failure messages pollute the Gitea
system notices with noise.

Add the field SKIP_REPOS to the [cron.repo_health_check] section of
app.ini which is a list of repos for which to skip the health check.

Implements: go-gitea#1712
Signed-off-by: Allen Wild <allenwild93@gmail.com>
  • Loading branch information
aswild committed Feb 24, 2018
1 parent fc265b0 commit 44681d5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions custom/conf/app.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ TIMEOUT = 60s
; Arguments for command 'git fsck', e.g. "--unreachable --tags"
; see more on http://git-scm.com/docs/git-fsck/1.7.5
ARGS =
; A list of repos which shouldn't be health-checked, e.g. "user1/repo1 user2/repo2"
SKIP_REPOS =

; Check repository statistics
[cron.check_repo_stats]
Expand Down
1 change: 1 addition & 0 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
- `SCHEDULE`: **every 24h**: Cron syntax for scheduling repository health check.
- `TIMEOUT`: **60s**: Time duration syntax for health check execution timeout.
- `ARGS`: **\<empty\>**: Arguments for command `git fsck`, e.g. `--unreachable --tags`.
- `SKIP_REPOS`: **\<empty\>**: A list of repos which shouldn't be health-checked, e.g. `user1/repo1 user2/repo2`

### Cron - Repository Statistics Check (`cron.check_repo_stats`)

Expand Down
8 changes: 8 additions & 0 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2171,6 +2171,14 @@ func GitFsck() {
Iterate(new(Repository),
func(idx int, bean interface{}) error {
repo := bean.(*Repository)
repoFullName := repo.FullName()
for _, skipName := range setting.Cron.RepoHealthCheck.SkipRepos {
if repoFullName == skipName {
desc := fmt.Sprintf("Skipping health check for repository %s", repoFullName)
log.Trace(desc)
return nil
}
}
repoPath := repo.RepoPath()
if err := git.Fsck(repoPath, setting.Cron.RepoHealthCheck.Timeout, setting.Cron.RepoHealthCheck.Args...); err != nil {
desc := fmt.Sprintf("Failed to health check repository (%s): %v", repoPath, err)
Expand Down
2 changes: 2 additions & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ var (
Schedule string
Timeout time.Duration
Args []string `delim:" "`
SkipRepos []string `delim:" "`
} `ini:"cron.repo_health_check"`
CheckRepoStats struct {
Enabled bool
Expand Down Expand Up @@ -418,6 +419,7 @@ var (
Schedule string
Timeout time.Duration
Args []string `delim:" "`
SkipRepos []string `delim:" "`
}{
Enabled: true,
RunAtStart: false,
Expand Down

0 comments on commit 44681d5

Please sign in to comment.