From 44681d5e4d9133db24344e25e1ac133b05769319 Mon Sep 17 00:00:00 2001 From: Allen Wild Date: Sat, 24 Feb 2018 16:30:25 -0500 Subject: [PATCH] Add option to skip health check for some repositories 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: https://github.com/go-gitea/gitea/issues/1712 Signed-off-by: Allen Wild --- custom/conf/app.ini.sample | 2 ++ docs/content/doc/advanced/config-cheat-sheet.en-us.md | 1 + models/repo.go | 8 ++++++++ modules/setting/setting.go | 2 ++ 4 files changed, 13 insertions(+) diff --git a/custom/conf/app.ini.sample b/custom/conf/app.ini.sample index 7876f0a7b6061..5185fae3623b5 100644 --- a/custom/conf/app.ini.sample +++ b/custom/conf/app.ini.sample @@ -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] diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 93b4da9d32b91..91fc4f1d00db6 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -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`: **\**: Arguments for command `git fsck`, e.g. `--unreachable --tags`. +- `SKIP_REPOS`: **\**: A list of repos which shouldn't be health-checked, e.g. `user1/repo1 user2/repo2` ### Cron - Repository Statistics Check (`cron.check_repo_stats`) diff --git a/models/repo.go b/models/repo.go index ba5b7b36aff51..e9ec1c6550695 100644 --- a/models/repo.go +++ b/models/repo.go @@ -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) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 9ef175d20efff..12ede8fad9916 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -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 @@ -418,6 +419,7 @@ var ( Schedule string Timeout time.Duration Args []string `delim:" "` + SkipRepos []string `delim:" "` }{ Enabled: true, RunAtStart: false,