Documentation ¶
Overview ¶
Package quota defines state structures for resource quota groups for snaps.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResolveCrossReferences ¶
ResolveCrossReferences takes a set of deserialized groups and sets all cross references amongst them using the unexported fields which are not serialized.
Types ¶
type Group ¶
type Group struct { // Name is the name of the quota group. This name is used the // name of the systemd slice underlying the quota group. // Certain names are reserved for future use: system, snapd, root, user. // Otherwise names following the same rules as snap names can be used. Name string `json:"name,omitempty"` // SubGroups is the set of sub-groups that are subject to this quota. // Sub-groups have their own limits, subject to the requirement that the // highest quota for a sub-group is that of the parent group. SubGroups []string `json:"sub-groups,omitempty"` // MemoryLimit is the limit of memory available to the processes in the // group where if the total used memory of all the processes exceeds the // limit, oom-killer is invoked which will start killing processes. The // specific behavior of which processes are killed is subject to the // ExhaustionBehavior. MemoryLimit is expressed in bytes. MemoryLimit quantity.Size `json:"memory-limit,omitempty"` // ParentGroup is the the parent group that this group is a child of. If it // is empty, then this is a "root" quota group. ParentGroup string `json:"parent-group,omitempty"` // Snaps is the set of snaps that is part of this quota group. If this is // empty then the underlying slice may not exist on the system. Snaps []string `json:"snaps,omitempty"` // contains filtered or unexported fields }
Group is a quota group of snaps, services or sub-groups that are all subject to specific resource quotas. The only quota resource types currently supported is memory, but this can be expanded in the future.
func (*Group) CurrentMemoryUsage ¶
CurrentMemoryUsage returns the current memory usage of the quota group. For quota groups which do not yet have a backing systemd slice on the system ( i.e. quota groups without any snaps in them), the memory usage is reported as 0.
func (*Group) NewSubGroup ¶
NewSubGroup creates a new sub group under the current group.
func (*Group) SliceFileName ¶
SliceFileName returns the name of the slice file that should be used for this quota group. This name will include all of the group's parents in the name. For example, a group named "bar" that is a child of the "foo" group will have a systemd slice name as "snap.foo-bar.slice". Note that the slice name may differ from the snapd friendly group name, mainly in the case that the group is a sub group.
type QuotaGroupSet ¶
type QuotaGroupSet struct {
// contains filtered or unexported fields
}
QuotaGroupSet is a set of quota groups, it is used for tracking a set of necessary quota groups using AddAllNecessaryGroups to add groups (and their implicit dependencies), and AllQuotaGroups to enumerate all the quota groups in the set.
func (*QuotaGroupSet) AddAllNecessaryGroups ¶
func (s *QuotaGroupSet) AddAllNecessaryGroups(grp *Group) error
AddAllNecessaryGroups adds all groups that are required for the specified group to be effective to the set. This means all sub-groups of this group, all parent groups of this group, and all sub-trees of any parent groups. This set is the set of quota groups that must exist for this quota group to be fully realized on a system, since all sub-branches of the full tree must exist since this group may share some quota resources with the other branches. There is no support for manipulating group trees while accumulating to a QuotaGroupSet using this.
func (*QuotaGroupSet) AllQuotaGroups ¶
func (s *QuotaGroupSet) AllQuotaGroups() []*Group
AllQuotaGroups returns a flattend list of all quota groups and necessary quota groups that have been added to the set.