Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Cai <jcai@gitlab.com>2022-04-08 20:53:42 +0300
committerJohn Cai <jcai@gitlab.com>2022-04-08 20:53:42 +0300
commite9aa2ce490e68388607ed87fcea4270e13de4440 (patch)
treea15e9428a86e9c326fe05aa3aa204bd96a2a8cfb
parent3217e4f067bc7c6555485b48d96f1b1151acbecc (diff)
repocleaner: Allow NewWalker to receive grace period parameter
The Walker is used by both the periodic job that checks for untracked repositories as well as the list-untracked-repositories subcommand. It is useful to be able to give it a different grace period value. Add this parameter to the signature.
-rw-r--r--internal/praefect/repocleaner/repository.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/internal/praefect/repocleaner/repository.go b/internal/praefect/repocleaner/repository.go
index aeff3ac7d..afc8fd317 100644
--- a/internal/praefect/repocleaner/repository.go
+++ b/internal/praefect/repocleaner/repository.go
@@ -65,7 +65,7 @@ func NewRunner(cfg Cfg, logger logrus.FieldLogger, healthChecker praefect.Health
logger: logger.WithField("component", "repocleaner.repository_existence"),
healthChecker: healthChecker,
conns: conns,
- walker: NewWalker(conns, cfg.RepositoriesInBatch),
+ walker: NewWalker(conns, cfg.RepositoriesInBatch, 24*time.Hour),
stateOwner: stateOwner,
acquirer: acquirer,
action: action,
@@ -155,13 +155,14 @@ func (gs *Runner) loggerWith(virtualStorage, storage string) logrus.FieldLogger
// Walker allows walk by the repositories of the gitaly storage.
type Walker struct {
- conns praefect.Connections
- batchSize int
+ conns praefect.Connections
+ gracePeriod time.Duration
+ batchSize int
}
// NewWalker returns a new *Walker instance.
-func NewWalker(conns praefect.Connections, batchSize int) *Walker {
- return &Walker{conns: conns, batchSize: batchSize}
+func NewWalker(conns praefect.Connections, batchSize int, gracePeriod time.Duration) *Walker {
+ return &Walker{conns: conns, batchSize: batchSize, gracePeriod: gracePeriod}
}
// ExecOnRepositories runs through all the repositories on a Gitaly storage and executes the provided action.
@@ -189,7 +190,7 @@ func (wr *Walker) ExecOnRepositories(ctx context.Context, virtualStorage, storag
// repositories that are in the process of being created, where
// they do not yet have a record in Praefect.
- if res.GetModificationTime().AsTime().After(time.Now().Add(-24 * time.Hour)) {
+ if res.GetModificationTime().AsTime().After(time.Now().Add(-wr.gracePeriod)) {
continue
}