Skip to content

Add option to skip health check for some repositories #3577

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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