ratio

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorDisabled error = errors.New("request ratio validation disabled")

ErrorDisabled is returned if the request ratio validation is disabled

View Source
var RatioValidatiorDisableAnnotation = "validate-request-ratio.appuio.io/disable"

RatioValidatiorDisableAnnotation is the key for an annotion on a namespace to disable request ratio warnings

Functions

This section is empty.

Types

type Fetcher

type Fetcher struct {
	Client client.Client

	OrganizationLabel string
}

Fetcher collects the CPU to memory request ratio

func (Fetcher) FetchRatios added in v0.8.0

func (f Fetcher) FetchRatios(ctx context.Context, name string) (map[string]*Ratio, error)

FetchRatios collects the CPU to memory request ratio for the given namespace grouped by `.spec.nodeSelector`.

type Ratio

type Ratio struct {
	CPU    *inf.Dec
	Memory *inf.Dec
}

Ratio records resource requests and can calculate the current memory to CPU request ratio

func NewRatio

func NewRatio() *Ratio

NewRatio returns an initialized Ratio

func (Ratio) Below

func (r Ratio) Below(limit resource.Quantity) bool

Below returns if the memory to CPU ratio of the recorded objects is below the given limit. Always returns false if no CPU is requested.

func (Ratio) Ratio

func (r Ratio) Ratio() *resource.Quantity

Ratio returns the memory to CPU ratio of the recorded objects. Returns nil if there are no CPU requests. Ratio rounds up to the nearest MiB

func (*Ratio) RecordDeployment

func (r *Ratio) RecordDeployment(deps ...appsv1.Deployment) *Ratio

RecordDeployment collects all requests in the given deployment(s) and adds it to the ratio

func (*Ratio) RecordPod

func (r *Ratio) RecordPod(pods ...corev1.Pod) *Ratio

RecordPod collects all requests in the given Pod(s), and adds it to the ratio The function only considers pods in phase `Running`.

func (*Ratio) RecordStatefulSet

func (r *Ratio) RecordStatefulSet(stss ...appsv1.StatefulSet) *Ratio

RecordStatefulSet collects all requests in the given StatefulSet(s) and adds it to the ratio

func (Ratio) String

func (r Ratio) String() string

String implements Stringer to print ratio

func (Ratio) Warn

func (r Ratio) Warn(limit *resource.Quantity, nodeSelector string) string

Warn returns a warning string explaining that the ratio is not considered fair use

Jump to

Keyboard shortcuts

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