diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2021-09-30 17:30:33 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2021-09-30 17:30:33 +0300 |
commit | eeca095e5680831ad140c2338d0f1c7d8b06a1ba (patch) | |
tree | 1c1f2ccd890d807a75f23c1ae1244d50bb5f0e48 /cmd | |
parent | 0bf16fc55108fa4ff170ed8a77f104d99f359151 (diff) | |
parent | c378f639b0ac6aa983dd0dae2f5940d3c36dd103 (diff) |
Merge branch 'ps-crowler' into 'master'
repocleaner: Log warning message for repositories not known to praefect
Closes #3719
See merge request gitlab-org/gitaly!3839
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/praefect/main.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cmd/praefect/main.go b/cmd/praefect/main.go index 5a6c54d0c..6470c52c9 100644 --- a/cmd/praefect/main.go +++ b/cmd/praefect/main.go @@ -84,6 +84,7 @@ import ( "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/nodes/tracker" "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/protoregistry" "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/reconciler" + "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/repocleaner" "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/service/transaction" "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/transactions" "gitlab.com/gitlab-org/gitaly/v14/internal/version" @@ -446,6 +447,29 @@ func run(cfgs []starter.Config, conf config.Config) error { } } + if interval := conf.RepositoriesCleanup.RunInterval.Duration(); interval > 0 { + if db != nil { + go func() { + storageSync := datastore.NewStorageCleanup(db) + cfg := repocleaner.Cfg{ + RunInterval: conf.RepositoriesCleanup.RunInterval.Duration(), + LivenessInterval: 30 * time.Second, + RepositoriesInBatch: conf.RepositoriesCleanup.RepositoriesInBatch, + } + repoCleaner := repocleaner.NewRunner(cfg, logger, healthChecker, nodeSet.Connections(), storageSync, storageSync, repocleaner.NewLogWarnAction(logger)) + if err := repoCleaner.Run(ctx, helper.NewTimerTicker(conf.RepositoriesCleanup.CheckInterval.Duration())); err != nil && !errors.Is(context.Canceled, err) { + logger.WithError(err).Error("repository cleaner finished execution") + } else { + logger.Info("repository cleaner finished execution") + } + }() + } else { + logger.Warn("Repository cleanup background task disabled as there is no database connection configured.") + } + } else { + logger.Warn(`Repository cleanup background task disabled as "repositories_cleanup.run_interval" is not set or 0.`) + } + return b.Wait(conf.GracefulStopTimeout.Duration()) } |