Documentation ¶
Index ¶
- func PruneOldCgroups(cfg cgroups.Config, logger log.Logger)
- type AddCommandOption
- type CGroupManager
- func (cgm *CGroupManager) AddCommand(cmd *exec.Cmd, opts ...AddCommandOption) (string, error)
- func (cgm *CGroupManager) Cleanup() error
- func (cgm *CGroupManager) CloneIntoCgroup(cmd *exec.Cmd, opts ...AddCommandOption) (string, io.Closer, error)
- func (cgm *CGroupManager) Collect(ch chan<- prometheus.Metric)
- func (cgm *CGroupManager) Describe(ch chan<- *prometheus.Desc)
- func (cgm *CGroupManager) Ready() bool
- func (cgm *CGroupManager) Setup() error
- func (cgm *CGroupManager) Stats() (Stats, error)
- func (cgm *CGroupManager) SupportsCloneIntoCgroup() bool
- type CgroupStats
- type Manager
- type NoopManager
- func (cg *NoopManager) AddCommand(*exec.Cmd, ...AddCommandOption) (string, error)
- func (cg *NoopManager) Cleanup() error
- func (cg *NoopManager) CloneIntoCgroup(*exec.Cmd, ...AddCommandOption) (string, io.Closer, error)
- func (cg *NoopManager) Collect(ch chan<- prometheus.Metric)
- func (cg *NoopManager) Describe(ch chan<- *prometheus.Desc)
- func (cg *NoopManager) Ready() bool
- func (cg *NoopManager) Setup() error
- func (cg *NoopManager) Stats() (Stats, error)
- func (cg *NoopManager) SupportsCloneIntoCgroup() bool
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddCommandOption ¶
type AddCommandOption func(*addCommandCfg)
AddCommandOption is an option that can be passed to AddCommand.
func WithCgroupKey ¶
func WithCgroupKey(cgroupKey string) AddCommandOption
WithCgroupKey overrides the key used to derive the Cgroup bucket. If not passed, then the command arguments will be used as the cgroup key.
type CGroupManager ¶ added in v16.2.0
type CGroupManager struct {
// contains filtered or unexported fields
}
CGroupManager is a manager class that implements specific methods related to cgroups
func (*CGroupManager) AddCommand ¶ added in v16.2.0
func (cgm *CGroupManager) AddCommand(cmd *exec.Cmd, opts ...AddCommandOption) (string, error)
AddCommand adds a Cmd to a cgroup
func (*CGroupManager) Cleanup ¶ added in v16.2.0
func (cgm *CGroupManager) Cleanup() error
Cleanup cleans up cgroups created in Setup.
func (*CGroupManager) CloneIntoCgroup ¶ added in v16.6.0
func (cgm *CGroupManager) CloneIntoCgroup(cmd *exec.Cmd, opts ...AddCommandOption) (string, io.Closer, error)
CloneIntoCgroup configures the cgroup parameters UseCgroupFD and CgroupFD in SysProcAttr to start the command directly in the correct cgroup. On success, the function returns an io.Closer that must be closed after the command has been started to close the cgroup's file descriptor.
func (*CGroupManager) Collect ¶ added in v16.2.0
func (cgm *CGroupManager) Collect(ch chan<- prometheus.Metric)
Collect is used to collect the current values of all CGroupManager prometheus metrics
func (*CGroupManager) Describe ¶ added in v16.2.0
func (cgm *CGroupManager) Describe(ch chan<- *prometheus.Desc)
Describe is used to generate description information for each CGroupManager prometheus metric
func (*CGroupManager) Ready ¶ added in v16.3.0
func (cgm *CGroupManager) Ready() bool
Ready returns true if the Cgroup manager is configured and ready to use.
func (*CGroupManager) Setup ¶ added in v16.2.0
func (cgm *CGroupManager) Setup() error
Setup parent cgroups and repository sub cgroups
func (*CGroupManager) Stats ¶ added in v16.3.0
func (cgm *CGroupManager) Stats() (Stats, error)
Stats returns cgroup accounting statistics collected by reading cgroupfs files.
func (*CGroupManager) SupportsCloneIntoCgroup ¶ added in v16.6.0
func (cgm *CGroupManager) SupportsCloneIntoCgroup() bool
SupportsCloneIntoCgroup returns whether this Manager supports the CloneIntoCgroup method. CloneIntoCgroup requires CLONE_INTO_CGROUP which is only supported with cgroup version 2 with Linux 5.7 or newer.
type CgroupStats ¶ added in v16.3.0
type CgroupStats struct { // CPUThrottledCount is much the CPU was throttled, this field is fetched from the `nr_throttled` field of // `cpu.stat` file. CPUThrottledCount uint64 // CPUThrottledCount is the accumulated duration of CPU throttled time in seconds. It is from the // `throttled_time` (V1) or the `throttled_usec` (v2) field of the `cpu.stat` file. CPUThrottledDuration float64 // MemoryUsage is the current memory usage in bytes of a cgroup. It's fetched from the `memory.usage_in_bytes` // (V1) or the `memory.current` (V2) files. MemoryUsage uint64 // MemoryLimit is the current memory limit in bytes of a cgroup. It's from the `memory.limit_in_bytes` (V1) or // the `memory.max` (V2) files. MemoryLimit uint64 // OOMKills is the accumulated count when the cgroup is being OOM-ed. It's read from the `memory.oom_control` // (V1) and the `memory.events` (V2) files. OOMKills uint64 // UnderOOM is the current OOM status of a cgroup. This information is available for Cgroup V1 only. It's read // from the `memory.oom_control` file. UnderOOM bool // Anon reflects the `rss` (V1) or `anon` (V2) of `memory.stat` file. That's amount of memory used in anonymous mappings Anon uint64 // ActiveAnon reflects the `active_file` of `memory.stat` file, anonymous and swap cache memory on active LRU list. ActiveAnon uint64 // InactiveAnon reflects the `inactive_anon` of `memory.stat` file, anonymous and swap cache memory on inactive LRU list. InactiveAnon uint64 // File reflects the `cache` (V1) or `file` (V2) of `memory.stat` file, bytes of page cache memory. File uint64 // ActiveFile reflects the `active_file` of `memory.stat` file, bytes of file-backed memory that cannot be reclaimed. ActiveFile uint64 // InactiveFile reflects the `inactive_file` of `memory.stat` file, bytes of file-backed memory on inactive LRU list. InactiveFile uint64 }
CgroupStats stores the current usage statistics of the resources managed by cgroup manager. They are fetched from the cgroupfs statistic files.
type Manager ¶
type Manager interface { // Setup creates cgroups and assigns configured limitations. // It is expected to be called once at Gitaly startup from any // instance of the Manager. Setup() error // Ready returns true if this cgroup manager is configured and // ready to use. Ready() bool // AddCommand adds a Cmd to a cgroup. AddCommand(*exec.Cmd, ...AddCommandOption) (string, error) // SupportsCloneIntoCgroup returns whether this Manager supports the CloneIntoCgroup method. // CloneIntoCgroup requires CLONE_INTO_CGROUP which is only supported with cgroups version 2 // with Linux 5.7 or newer. SupportsCloneIntoCgroup() bool // CloneIntoCgroup configures the cgroup parameters UseCgroupFD and CgroupFD in SysProcAttr // to start the command directly in the correct cgroup. On success, the function returns an io.Closer // that must be closed after the command has been started to close the cgroup's file descriptor. CloneIntoCgroup(*exec.Cmd, ...AddCommandOption) (string, io.Closer, error) // Cleanup cleans up cgroups created in Setup. // It is expected to be called once at Gitaly shutdown from any // instance of the Manager. Cleanup() error // Stats returns cgroup accounting statistics collected by reading // cgroupfs files. Those statistics are generic for both Cgroup V1 // and Cgroup V2. Stats() (Stats, error) Describe(ch chan<- *prometheus.Desc) Collect(ch chan<- prometheus.Metric) }
Manager supplies an interface for interacting with cgroups
type NoopManager ¶
type NoopManager struct{}
NoopManager is a cgroups manager that does nothing
func (*NoopManager) AddCommand ¶
func (cg *NoopManager) AddCommand(*exec.Cmd, ...AddCommandOption) (string, error)
func (*NoopManager) Cleanup ¶
func (cg *NoopManager) Cleanup() error
func (*NoopManager) CloneIntoCgroup ¶ added in v16.6.0
func (cg *NoopManager) CloneIntoCgroup(*exec.Cmd, ...AddCommandOption) (string, io.Closer, error)
CloneIntoCgroup does nothing.
func (*NoopManager) Collect ¶
func (cg *NoopManager) Collect(ch chan<- prometheus.Metric)
Collect does nothing
func (*NoopManager) Describe ¶
func (cg *NoopManager) Describe(ch chan<- *prometheus.Desc)
Describe does nothing
func (*NoopManager) Ready ¶ added in v16.3.0
func (cg *NoopManager) Ready() bool
func (*NoopManager) Setup ¶
func (cg *NoopManager) Setup() error
func (*NoopManager) Stats ¶ added in v16.3.0
func (cg *NoopManager) Stats() (Stats, error)
func (*NoopManager) SupportsCloneIntoCgroup ¶ added in v16.6.0
func (cg *NoopManager) SupportsCloneIntoCgroup() bool
SupportsCloneIntoCgroup returns false.
type Stats ¶ added in v16.3.0
type Stats struct { // ParentStats stores the statistics of the parent cgroup. There should be // an array of per-repository cgroups, but we haven't used that information // yet. ParentStats CgroupStats }
Stats stores statistics of all cgroups managed by a manager