Skip to content

Commit 8606d9f

Browse files
aswildlafriks
authored andcommitted
Add admin dashboard option to run health checks (#3606)
There's one for git gc, why not git fsck too? Also add a couple more trace logs to GitFsck to see progress
1 parent 2cd3622 commit 8606d9f

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

models/repo.go

+2
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,7 @@ func GitFsck() {
21722172
func(idx int, bean interface{}) error {
21732173
repo := bean.(*Repository)
21742174
repoPath := repo.RepoPath()
2175+
log.Trace(fmt.Sprintf("Running health check for repository %s", repoPath))
21752176
if err := git.Fsck(repoPath, setting.Cron.RepoHealthCheck.Timeout, setting.Cron.RepoHealthCheck.Args...); err != nil {
21762177
desc := fmt.Sprintf("Failed to health check repository (%s): %v", repoPath, err)
21772178
log.Warn(desc)
@@ -2183,6 +2184,7 @@ func GitFsck() {
21832184
}); err != nil {
21842185
log.Error(4, "GitFsck: %v", err)
21852186
}
2187+
log.Trace("Finished: GitFsck")
21862188
}
21872189

21882190
// GitGcRepos calls 'git gc' to remove unnecessary files and optimize the local repository

options/locale/locale_en-US.ini

+2
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,8 @@ dashboard.reinit_missing_repos = Reinitialize all missing Git repositories for w
12201220
dashboard.reinit_missing_repos_success = All missing Git repositories for which records existed have been reinitialized.
12211221
dashboard.sync_external_users = Synchronize external user data
12221222
dashboard.sync_external_users_started = External user synchronization started
1223+
dashboard.git_fsck = Execute health checks on all repositories
1224+
dashboard.git_fsck_started = Repository health checks started
12231225
dashboard.server_uptime = Server Uptime
12241226
dashboard.current_goroutine = Current Goroutines
12251227
dashboard.current_memory_usage = Current Memory Usage

routers/admin/admin.go

+4
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ const (
122122
syncRepositoryUpdateHook
123123
reinitMissingRepository
124124
syncExternalUsers
125+
gitFsck
125126
)
126127

127128
// Dashboard show admin panel dashboard
@@ -161,6 +162,9 @@ func Dashboard(ctx *context.Context) {
161162
case syncExternalUsers:
162163
success = ctx.Tr("admin.dashboard.sync_external_users_started")
163164
go models.SyncExternalUsers()
165+
case gitFsck:
166+
success = ctx.Tr("admin.dashboard.git_fsck_started")
167+
go models.GitFsck()
164168
}
165169

166170
if err != nil {

templates/admin/dashboard.tmpl

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
<td>{{.i18n.Tr "admin.dashboard.sync_external_users"}}</td>
5050
<td><i class="fa fa-caret-square-o-right"></i> <a href="{{AppSubUrl}}/admin?op=8">{{.i18n.Tr "admin.dashboard.operation_run"}}</a></td>
5151
</tr>
52+
<tr>
53+
<td>{{.i18n.Tr "admin.dashboard.git_fsck"}}</td>
54+
<td><i class="fa fa-caret-square-o-right"></i> <a href="{{AppSubUrl}}/admin?op=9">{{.i18n.Tr "admin.dashboard.operation_run"}}</a></td>
55+
</tr>
5256
</tbody>
5357
</table>
5458
</div>

0 commit comments

Comments
 (0)