priority

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PodEvictionAdmission

type PodEvictionAdmission interface {
	// LoopInit initializes PodEvictionAdmission for next Updater loop with the live pods and
	// pods currently controlled by MPA in this cluster.
	LoopInit(allLivePods []*apiv1.Pod, mpaControlledPods map[*mpa_types.MultidimPodAutoscaler][]*apiv1.Pod)
	// Admit returns true if PodEvictionAdmission decides that pod can be evicted with given recommendation.
	Admit(pod *apiv1.Pod, recommendation *vpa_types.RecommendedPodResources) bool
	// CleanUp cleans up any state that PodEvictionAdmission may keep. Called
	// when no MPA objects are present in the cluster.
	CleanUp()
}

PodEvictionAdmission controls evictions of pods.

func NewDefaultPodEvictionAdmission

func NewDefaultPodEvictionAdmission() PodEvictionAdmission

NewDefaultPodEvictionAdmission constructs new PodEvictionAdmission that admits all pods.

func NewSequentialPodEvictionAdmission

func NewSequentialPodEvictionAdmission(admissions []PodEvictionAdmission) PodEvictionAdmission

NewSequentialPodEvictionAdmission constructs PodEvictionAdmission that will chain provided PodEvictionAdmission objects

type PodPriority

type PodPriority struct {
	// Is any container outside of the recommended range.
	OutsideRecommendedRange bool
	// Does any container want to grow.
	ScaleUp bool
	// Relative difference between the total requested and total recommended resources.
	ResourceDiff float64
}

PodPriority contains data for a pod update that can be used to prioritize between updates.

func (PodPriority) Less

func (p PodPriority) Less(other PodPriority) bool

Less returns true if p is lower than other.

type PriorityProcessor

type PriorityProcessor interface {
	GetUpdatePriority(pod *apiv1.Pod, mpa *mpa_types.MultidimPodAutoscaler,
		recommendation *vpa_types.RecommendedPodResources) PodPriority
}

PriorityProcessor calculates priority for pod updates.

func NewFakeProcessor

func NewFakeProcessor(priorities map[string]PodPriority) PriorityProcessor

NewFakeProcessor returns a fake processor for testing that can be initialized with a map from pod name to priority expected to be returned.

func NewProcessor

func NewProcessor() PriorityProcessor

NewProcessor creates a new default PriorityProcessor.

type UpdateConfig

type UpdateConfig struct {
	// MinChangePriority is the minimum change priority that will trigger a update.
	// TODO: should have separate for Mem and CPU?
	MinChangePriority float64
}

UpdateConfig holds configuration for UpdatePriorityCalculator

type UpdatePriorityCalculator

type UpdatePriorityCalculator struct {
	// contains filtered or unexported fields
}

UpdatePriorityCalculator is responsible for prioritizing updates on pods. It can returns a sorted list of pods in order of update priority. Update priority is proportional to fraction by which resources should be increased / decreased. i.e. pod with 10M current memory and recommendation 20M will have higher update priority than pod with 100M current memory and 150M recommendation (100% increase vs 50% increase)

func NewUpdatePriorityCalculator

func NewUpdatePriorityCalculator(mpa *mpa_types.MultidimPodAutoscaler,
	config *UpdateConfig,
	recommendationProcessor mpa_api_util.RecommendationProcessor,
	priorityProcessor PriorityProcessor) UpdatePriorityCalculator

NewUpdatePriorityCalculator creates new UpdatePriorityCalculator for the given MPA object an update config. If the MPA resource policy is nil, there will be no policy restriction on update. If the given update config is nil, default values are used.

func (*UpdatePriorityCalculator) AddPod

func (calc *UpdatePriorityCalculator) AddPod(pod *apiv1.Pod, now time.Time)

AddPod adds pod to the UpdatePriorityCalculator.

func (*UpdatePriorityCalculator) GetSortedPods

func (calc *UpdatePriorityCalculator) GetSortedPods(admission PodEvictionAdmission) []*apiv1.Pod

GetSortedPods returns a list of pods ordered by update priority (highest update priority first)

Jump to

Keyboard shortcuts

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