Documentation
¶
Index ¶
- Constants
- func NewContext(ctx context.Context) context.Context
- func UnifiedPath() string
- type CPUQuota
- type Config
- func (c Config) Apply() error
- func (c *Config) ApplyOnce() (bool, error)
- func (c Config) ApplyProc(pid int) (created bool, errs error)
- func (c *Config) Clean() (bool, error)
- func (c Config) Delete() (bool, error)
- func (c Config) String() string
- func (c Config) Uncapped() Config
- func (c *Config) WithLogger(l *plog.Logger) *Config
- type Mgr
Constants ¶
const DefaultValue = "default"
DefaultValue is the pg_* keyword value asking for the capping it names to be put back where a node that never capped anything leaves it.
Removing a keyword leaves the capping alone, on purpose: what om wrote stays, and so does what anything else wrote. That leaves no way of lifting a cap, which this value is. It is a value and not a command because the configuration is what every node of the cluster converges to: a node provisioned tomorrow, or a peer taking the object over, has to arrive at the same capping as the node the reset was asked on.
Variables ¶
This section is empty.
Functions ¶
func UnifiedPath ¶
func UnifiedPath() string
Types ¶
type CPUQuota ¶
type CPUQuota string
func (CPUQuota) Convert ¶
Convert returns the cpu.max quota of a pg_cpu_quota expression, for the period it is given.
The percentage is of the cpus the expression names, one when it names none, so for a 100000 period on a node having 4 cpu threads:
100%@all => 400000, the four of them 50% => 50000, half of one 10%@2 => 20000, a tenth of two
type Config ¶
type Config struct {
ID string
CPUs string
Mems string
CPUQuota string
MemOOMControl string
MemLimit string
VMemLimit string
MemSwappiness string
BlockIOWeight string
// contains filtered or unexported fields
}
func (Config) Apply ¶
Apply is a convenience method for compatibility. Use (*Config).Apply() for state-tracking apply.
func (*Config) ApplyOnce ¶
ApplyOnce applies the pg configuration if it hasn't been applied already. Returns true if the config was applied, false if it was already applied.
func (Config) ApplyProc ¶
ApplyProc creates the cgroup, set caps, and add the specified process
On the unified hierarchy every value is written where the kernel keeps it, and the manager is asked only to make the cgroup and to delegate the controllers to it. It converts an oci runtime spec, whose weights are of the v1 hierarchy, and rescales them: a cpu weight of 1024 reached the kernel as 39, and a block io weight went to io.bfq.weight, a file only a kernel running the bfq scheduler has. It also cannot say a reset: it skips an empty cpuset, which is what clearing one is, and writes a memory limit as a number, where lifting one is the word "max".
The v1 hierarchy still goes through it, which is what it was written for.
Which of the two a node holds is read from the mode of its cgroup mounts, not from the unified manager failing. Falling back on a failure confused a node having no unified hierarchy with a write that went wrong on one, and the second sent the apply down a v1 path that could only fail differently: that is how a missing io.bfq.weight was reported as a missing v1 mountpoint.
func (Config) String ¶
String is what an applied group logs, so it names the cappings that were applied and not the ones this node has no file for.
func (Config) Uncapped ¶
Clean removes the pg configuration if it was applied. Uncapped returns the same group, with every capping the unified hierarchy has a file for asked to go back where the kernel leaves it.
It is what "pg reset" applies. The keywords a configuration carries are not read: the point of the command is to lift cappings the configuration does not know about, left by an older agent, by systemd, or by hand.
type Mgr ¶
type Mgr struct {
// contains filtered or unexported fields
}
func FromContext ¶
func (*Mgr) ApplyConfigs ¶
ApplyConfigs applies all registered pg configs in order (base to leaf). Each config is applied only if not already applied.
func (*Mgr) ResetConfigs ¶
ResetConfigs lifts the capping of the registered groups at and under the reset root, base to leaf, each one once.
The order matters the same way it does when capping: a parent has to be uncapped before a child, or the child stays capped by what the parent still holds. Sorting the ids gives that order, a parent being a prefix of its children.
It is called once per resource of the walk, as applying is, and lifts on each call only what the calls before it did not: a resource registers its group and the groups registered so far are already lifted.
func (*Mgr) SetResetRoot ¶
SetResetRoot says which of the registered groups an action may lift the capping of: that one, and the ones under it.
It is what keeps an object from uncapping what it does not own. The groups registered by an action reach above the object, up to the slice of the namespace and the slice holding every object of the node, because a child cannot be capped before its parents exist. Those are the namespace's to lift, not this object's.