config

package
v15.7.5 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PackObjectsLimitingKeyUser will limit the pack objects concurrency
	// by user
	PackObjectsLimitingKeyUser = PackObjectsLimitingKey("user")
	// PackObjectsLimitingKeyRepository will limit the pack objects concurrency
	// by repository
	PackObjectsLimitingKeyRepository = PackObjectsLimitingKey("repository")
)
View Source
const (
	// GitalyDataPrefix is the top-level directory we use to store system
	// (non-user) data. We need to be careful that this path does not clash
	// with any directory name that could be provided by a user. The '+'
	// character is not allowed in GitLab namespaces or repositories.
	GitalyDataPrefix = "+gitaly"
)

Variables

This section is empty.

Functions

func GetGitalyProcessTempDir added in v15.4.0

func GetGitalyProcessTempDir(parentDir string, processID int) string

GetGitalyProcessTempDir constructs a temporary directory name for the current gitaly process. This way, we can clean up old temporary directories by inspecting the pid attached to the folder.

func NewLocator

func NewLocator(conf Cfg) storage.Locator

NewLocator returns locator based on the provided configuration struct. As it creates a shallow copy of the provided struct changes made into provided struct may affect result of methods implemented by it.

func PruneOldGitalyProcessDirectories added in v15.4.0

func PruneOldGitalyProcessDirectories(log log.FieldLogger, directory string) error

PruneOldGitalyProcessDirectories removes leftover temporary directories that belonged to processes that no longer exist. Directories are expected to be in the form gitaly-<pid>. The removals are logged prior to being executed. Unexpected directory entries are logged but not removed.

func SetupRuntimeDirectory added in v15.2.0

func SetupRuntimeDirectory(cfg Cfg, processID int) (string, error)

SetupRuntimeDirectory creates a new runtime directory. Runtime directory contains internal runtime data generated by Gitaly such as the internal sockets. If cfg.RuntimeDir is set, it's used as the parent directory for the runtime directory. Runtime directory owner process can be identified by the suffix process ID suffixed in the directory name. If a directory already exists for this process' ID, it's removed and recreated. If cfg.RuntimeDir is not set, a temporary directory is used instead. A directory is created for the internal socket as well since it is expected to be present in the runtime directory. SetupRuntimeDirectory returns the absolute path to the created runtime directory.

Types

type Cfg

type Cfg struct {
	SocketPath             string              `toml:"socket_path" split_words:"true"`
	ListenAddr             string              `toml:"listen_addr" split_words:"true"`
	TLSListenAddr          string              `toml:"tls_listen_addr" split_words:"true"`
	PrometheusListenAddr   string              `toml:"prometheus_listen_addr" split_words:"true"`
	BinDir                 string              `toml:"bin_dir"`
	RuntimeDir             string              `toml:"runtime_dir"`
	Git                    Git                 `toml:"git" envconfig:"git"`
	Storages               []Storage           `toml:"storage" envconfig:"storage"`
	Logging                Logging             `toml:"logging" envconfig:"logging"`
	Prometheus             prometheus.Config   `toml:"prometheus"`
	Auth                   auth.Config         `toml:"auth"`
	TLS                    TLS                 `toml:"tls"`
	Ruby                   Ruby                `toml:"gitaly-ruby"`
	Gitlab                 Gitlab              `toml:"gitlab"`
	GitlabShell            GitlabShell         `toml:"gitlab-shell"`
	Hooks                  Hooks               `toml:"hooks"`
	Concurrency            []Concurrency       `toml:"concurrency"`
	RateLimiting           []RateLimiting      `toml:"rate_limiting"`
	GracefulRestartTimeout duration.Duration   `toml:"graceful_restart_timeout"`
	DailyMaintenance       DailyJob            `toml:"daily_maintenance"`
	Cgroups                cgroups.Config      `toml:"cgroups"`
	PackObjectsCache       StreamCacheConfig   `toml:"pack_objects_cache"`
	PackObjectsLimiting    PackObjectsLimiting `toml:"pack_objects_limiting"`
}

Cfg is a container for all config derived from config.toml.

func Load

func Load(file io.Reader) (Cfg, error)

Load initializes the Config variable from file and the environment. Environment variables take precedence over the file.

func (*Cfg) BinaryPath added in v15.2.0

func (cfg *Cfg) BinaryPath(binaryName string) string

BinaryPath returns the path to a given binary. BinaryPath does not do any validation, it simply joins the binaryName with the correct base directory depending on whether the binary is a packed binary or not.

func (*Cfg) ConfigureRuby

func (cfg *Cfg) ConfigureRuby() error

ConfigureRuby validates the gitaly-ruby configuration and sets default values.

func (*Cfg) InternalSocketDir

func (cfg *Cfg) InternalSocketDir() string

InternalSocketDir returns the location of the internal socket directory.

func (*Cfg) InternalSocketPath

func (cfg *Cfg) InternalSocketPath() string

InternalSocketPath is the path to the internal Gitaly socket.

func (*Cfg) Storage

func (cfg *Cfg) Storage(storageName string) (Storage, bool)

Storage looks up storageName.

func (*Cfg) StoragePath

func (cfg *Cfg) StoragePath(storageName string) (string, bool)

StoragePath looks up the base path for storageName. The second boolean return value indicates if anything was found.

func (*Cfg) Validate

func (cfg *Cfg) Validate() error

Validate checks the current Config for sanity.

type Concurrency

type Concurrency struct {
	// RPC is the name of the RPC to set concurrency limits for
	RPC string `toml:"rpc"`
	// MaxPerRepo is the maximum number of concurrent calls for a given repository
	MaxPerRepo int `toml:"max_per_repo"`
	// MaxQueueSize is the maximum number of requests in the queue waiting to be picked up
	// after which subsequent requests will return with an error.
	MaxQueueSize int `toml:"max_queue_size"`
	// MaxQueueWait is the maximum time a request can remain in the concurrency queue
	// waiting to be picked up by Gitaly
	MaxQueueWait duration.Duration `toml:"max_queue_wait"`
}

Concurrency allows endpoints to be limited to a maximum concurrency per repo. Requests that come in after the maximum number of concurrent requests are in progress will wait in a queue that is bounded by MaxQueueSize.

type DailyJob

type DailyJob struct {
	Hour     uint              `toml:"start_hour"`
	Minute   uint              `toml:"start_minute"`
	Duration duration.Duration `toml:"duration"`
	Storages []string          `toml:"storages"`

	// Disabled will completely disable a daily job, even in cases where a
	// default schedule is implied
	Disabled bool `toml:"disabled"`
}

DailyJob enables a daily task to be scheduled for specific storages

type Git

type Git struct {
	UseBundledBinaries bool        `toml:"use_bundled_binaries"`
	BinPath            string      `toml:"bin_path"`
	CatfileCacheSize   int         `toml:"catfile_cache_size"`
	Config             []GitConfig `toml:"config"`
	IgnoreGitconfig    bool        `toml:"ignore_gitconfig"`
	SigningKey         string      `toml:"signing_key"`
}

Git contains the settings for the Git executable

type GitConfig

type GitConfig struct {
	Key   string `toml:"key"`
	Value string `toml:"value"`
}

GitConfig contains a key-value pair which is to be passed to git as configuration.

type Gitlab

type Gitlab struct {
	URL             string       `toml:"url" json:"url"`
	RelativeURLRoot string       `toml:"relative_url_root" json:"relative_url_root"` // For UNIX sockets only
	HTTPSettings    HTTPSettings `toml:"http-settings" json:"http_settings"`
	SecretFile      string       `toml:"secret_file" json:"secret_file"`
}

Gitlab contains settings required to connect to the Gitlab api

type GitlabShell

type GitlabShell struct {
	Dir string `toml:"dir" json:"dir"`
}

GitlabShell contains the settings required for executing `gitlab-shell`

type HTTPSettings

type HTTPSettings struct {
	ReadTimeout int    `toml:"read_timeout" json:"read_timeout"`
	User        string `toml:"user" json:"user"`
	Password    string `toml:"password" json:"password"`
	CAFile      string `toml:"ca_file" json:"ca_file"`
	CAPath      string `toml:"ca_path" json:"ca_path"`
}

type Hooks

type Hooks struct {
	CustomHooksDir string `toml:"custom_hooks_dir" json:"custom_hooks_dir"`
}

Hooks contains the settings required for hooks

type Logging

type Logging struct {
	internallog.Config
	Sentry

	RubySentryDSN string `toml:"ruby_sentry_dsn"`
}

Logging contains the logging configuration for Gitaly

type PackObjectsLimiting added in v15.6.0

type PackObjectsLimiting struct {
	// Key is the key by which concurrency will be limited. Supported keys
	// are: user_id, repository.
	Key PackObjectsLimitingKey `toml:"key,omitempty"`
	// MaxConcurrency is the maximum number of concurrent pack objects processes
	// for a given key.
	MaxConcurrency int `toml:"max_concurrency,omitempty"`
	// MaxQueueWait is the maximum time a request can remain in the concurrency queue
	// waiting to be picked up by Gitaly.
	MaxQueueWait duration.Duration `toml:"max_queue_wait,omitempty"`
}

PackObjectsLimiting allows the concurrency of pack objects processes to be limited Requests that come in after the maximum number of concurrent pack objects processes have been reached will wait.

type PackObjectsLimitingKey added in v15.6.0

type PackObjectsLimitingKey string

PackObjectsLimitingKey is the key for limiting pack objects concurrency

func ParsePackObjectsLimitingKey added in v15.6.0

func ParsePackObjectsLimitingKey(k string) (PackObjectsLimitingKey, error)

ParsePackObjectsLimitingKey checks if the key is a valid PackObjectsLimitingKey

func (*PackObjectsLimitingKey) UnmarshalText added in v15.6.0

func (p *PackObjectsLimitingKey) UnmarshalText(text []byte) error

UnmarshalText unmarshals a key into a ParsePackObjectsLimitingKey

type RateLimiting

type RateLimiting struct {
	// RPC is the full name of the RPC including the service name
	RPC string `toml:"rpc"`
	// Interval sets the interval with which the token bucket will
	// be refilled to what is configured in Burst.
	Interval duration.Duration `toml:"interval"`
	// Burst sets the capacity of the token bucket (see above).
	Burst int `toml:"burst"`
}

RateLimiting allows endpoints to be limited to a maximum request rate per second. The rate limiter uses a concept of a "token bucket". In order to serve a request, a token is retrieved from the token bucket. The size of the token bucket is configured through the Burst value, while the rate at which the token bucket is refilled per second is configured through the RequestsPerSecond value.

type Ruby

type Ruby struct {
	Dir                       string            `toml:"dir"`
	MaxRSS                    int               `toml:"max_rss"`
	GracefulRestartTimeout    duration.Duration `toml:"graceful_restart_timeout"`
	RestartDelay              duration.Duration `toml:"restart_delay"`
	NumWorkers                int               `toml:"num_workers"`
	RuggedGitConfigSearchPath string            `toml:"rugged_git_config_search_path"`
}

Ruby contains setting for Ruby worker processes

type Sentry

type Sentry sentry.Config

Sentry is a sentry.Config. We redefine this type to a different name so we can embed both structs into Logging

type Storage

type Storage struct {
	Name string
	Path string
}

Storage contains a single storage-shard

type StreamCacheConfig

type StreamCacheConfig struct {
	Enabled bool              `toml:"enabled"` // Default: false
	Dir     string            `toml:"dir"`     // Default: <FIRST STORAGE PATH>/+gitaly/PackObjectsCache
	MaxAge  duration.Duration `toml:"max_age"` // Default: 5m
}

StreamCacheConfig contains settings for a streamcache instance.

type TLS

type TLS struct {
	CertPath string `toml:"certificate_path,omitempty" json:"cert_path"`
	KeyPath  string `toml:"key_path,omitempty" json:"key_path"`
}

TLS configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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