repocleaner

package
v15.11.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Acquirer

type Acquirer interface {
	// Populate adds provided storage into the pool of entries to acquire.
	Populate(ctx context.Context, virtualStorage, storage string) error
	// AcquireNextStorage acquires next storage based on the inactive time.
	AcquireNextStorage(ctx context.Context, inactive, updatePeriod time.Duration) (*datastore.ClusterPath, func() error, error)
}

Acquirer acquires storage for processing and no any other Acquirer can acquire it again until it is released.

type Action

type Action interface {
	// Perform runs actual action for non-existing repositories.
	Perform(ctx context.Context, virtualStorage, storage string, replicaPaths []string) error
}

Action is a procedure to be executed on the repositories that doesn't exist in praefect database.

type Cfg

type Cfg struct {
	// RunInterval: the check runs if the previous operation was done at least RunInterval before.
	RunInterval time.Duration
	// LivenessInterval: an update runs on the locked entity with provided period to signal that entity is in use.
	LivenessInterval time.Duration
	// RepositoriesInBatch is the number of repositories to pass as a batch for processing.
	RepositoriesInBatch int
}

Cfg contains set of configuration parameters to run Runner.

type LogWarnAction

type LogWarnAction struct {
	// contains filtered or unexported fields
}

LogWarnAction is an implementation of the Action interface that allows to log a warning message for the repositories that are not known for the praefect.

func NewLogWarnAction

func NewLogWarnAction(logger logrus.FieldLogger) *LogWarnAction

NewLogWarnAction return new instance of the LogWarnAction.

func (LogWarnAction) Perform

func (al LogWarnAction) Perform(_ context.Context, virtualStorage, storage string, replicaPaths []string) error

Perform logs a warning for each repository that is not known to praefect.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner scans healthy gitaly nodes for the repositories, verifies if found repositories are known by praefect and runs a special action.

func NewRunner

func NewRunner(cfg Cfg, logger logrus.FieldLogger, healthChecker praefect.HealthChecker, conns praefect.Connections, stateOwner StateOwner, acquirer Acquirer, action Action) *Runner

NewRunner returns instance of the Runner.

func (*Runner) Run

func (gs *Runner) Run(ctx context.Context, ticker helper.Ticker) error

Run scans healthy gitaly nodes for the repositories, verifies if found repositories are known by praefect and runs a special action. It runs on each tick of the provided ticker and finishes with context cancellation.

type StateOwner

type StateOwner interface {
	// DoesntExist returns replica path for each repository that doesn't exist in the database
	// by querying repositories and storage_repositories tables.
	DoesntExist(ctx context.Context, virtualStorage, storage string, replicaPaths []string) ([]string, error)
}

StateOwner performs check for the existence of the repositories.

type Walker

type Walker struct {
	// contains filtered or unexported fields
}

Walker allows walk by the repositories of the gitaly storage.

func NewWalker

func NewWalker(conns praefect.Connections, batchSize int, gracePeriod time.Duration) *Walker

NewWalker returns a new *Walker instance.

func (*Walker) ExecOnRepositories

func (wr *Walker) ExecOnRepositories(ctx context.Context, virtualStorage, storage string, action func(string, string, []string) error) error

ExecOnRepositories runs through all the repositories on a Gitaly storage and executes the provided action. The processing is done in batches to reduce cost of operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL