controller

package
v0.0.0-...-1761856 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultResourceLimitsPrefix = "limits."

Should be defined in api/core/v1/types.go

Variables

This section is empty.

Functions

func Dec2float64

func Dec2float64(d *inf.Dec) (float64, error)

Dec2float64 converts inf.Dec to float64

func RemoveDuplicateResources

func RemoveDuplicateResources(slice []v1.ResourceName) []v1.ResourceName

Remove duplicate resource names in a slice

Types

type AppWrapperReconciler

type AppWrapperReconciler struct {
	client.Client
	Scheme           *runtime.Scheme
	Cache            map[types.UID]*CachedAppWrapper // cache AppWrapper updates for write/read consistency
	MultiClusterMode bool                            // are we operating in multi-cluster mode
	ControllerName   string                          // name of the controller
}

AppWrapperReconciler is the super type of Dispatcher and Runner reconcilers

type CachedAppWrapper

type CachedAppWrapper struct {
	// AppWrapper state
	State mcadv1beta1.AppWrapperState

	// AppWrapper step
	Step mcadv1beta1.AppWrapperStep

	// Number of transitions
	TransitionCount int32

	// First conflict detected between reconciler cache and our cache if not nil
	Conflict *time.Time
}

Cached AppWrapper

type ClusterInfoReconciler

type ClusterInfoReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

ClusterInfoReconciler reconciles a ClusterInfo object

func (*ClusterInfoReconciler) Reconcile

func (r *ClusterInfoReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile ClusterInfo object

func (*ClusterInfoReconciler) SetupWithManager

func (r *ClusterInfoReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type Dispatcher

type Dispatcher struct {
	AppWrapperReconciler
	Decisions          map[types.UID]*QueuingDecision // transient log of queuing decisions to enable recording in AppWrapper Status
	Events             chan event.GenericEvent        // event channel to trigger dispatch
	NextLoggedDispatch time.Time                      // when next to log dispatching decisions
}

AppWrapperReconciler responsible for the portion of the lifecycle that happens on the scheduling cluster

func (*Dispatcher) Reconcile

func (r *Dispatcher) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile one AppWrapper or dispatch queued AppWrappers during the dispatching phases of their lifecycle.

Normal reconciliations "namespace/name" implement all phase transitions except for Queued->Dispatching Queued->Dispatching transitions happen as part of a special "*/*" reconciliation In a "*/*" reconciliation, we iterate over queued AppWrappers in order, dispatching as many as we can

func (*Dispatcher) SetupWithManager

func (r *Dispatcher) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type PodCounts

type PodCounts struct {
	Other     int
	Running   int
	Succeeded int
}

PodCounts summarize the status of the pods associated with one AppWrapper

type QueuingDecision

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

type QuotaState

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

State includes total quota, used quota, and currently allocated quota

func NewQuotaStateFromResourceQuota

func NewQuotaStateFromResourceQuota(resourceQuota *v1.ResourceQuota) *QuotaState

Create a QuotaState from a ResourceQuota object

type QuotaTracker

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

A tracker of allocated quota, mapped by namespace

func NewQuotaTracker

func NewQuotaTracker() *QuotaTracker

Create a new QuotaTracker

func (*QuotaTracker) Allocate

func (tracker *QuotaTracker) Allocate(namespace string, appWrapperAskWeights *WeightsPair) bool

Update the QuotaState by the allocated weights of an AppWrapper in a namespace, fails if QuotaState does not exist in the QuotaTracker

func (*QuotaTracker) Init

func (tracker *QuotaTracker) Init(weightsPairMap map[string]*WeightsPair)

Account for all in-flight AppWrappers with their resource demand not yet reflected in the Used status of any ResourceQuota object in their corresponding namespace

func (*QuotaTracker) Satisfies

func (tracker *QuotaTracker) Satisfies(appWrapperAskWeights *WeightsPair, resourceQuota *v1.ResourceQuota) (bool, []v1.ResourceName)

Check if the resource demand of an AppWrapper satisfies a ResourceQuota, without changing the current quota allocation, returning resource names with insufficient quota

type Runner

type Runner struct {
	AppWrapperReconciler
}

AppWrapperReconciler responsible for the portion of the lifecycle that happens on the execution cluster

func (*Runner) Reconcile

func (r *Runner) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile one Running AppWrapper on an execution cluster and monitor health of its execution resources.

func (*Runner) SetupWithManager

func (r *Runner) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type Weights

type Weights map[v1.ResourceName]*inf.Dec

Weights represent a set of resource requests or available resources Quantities are encoded as *inf.Dec to maintain precision and make arithmetic easy

func NewLimitsWeightsForPod

func NewLimitsWeightsForPod(pod *v1.Pod) Weights

Converts resource limits of a pod to Weights

func NewWeights

func NewWeights(r v1.ResourceList) Weights

Converts a ResourceList to Weights

func NewWeightsForPod

func NewWeightsForPod(pod *v1.Pod) Weights

Converts effective resources of a pod to Weights

func (Weights) Add

func (w Weights) Add(r Weights)

Add weights to receiver

func (Weights) AddProd

func (w Weights) AddProd(coefficient int32, r Weights)

Add coefficient * weights to receiver

func (Weights) AsResources

func (w Weights) AsResources() v1.ResourceList

Converts Weights to a ResourceList

func (Weights) Clone

func (w Weights) Clone() Weights

Creates a (deep) copy of Weights (Easier to add to zero than creating all fields)

func (Weights) Fits

func (w Weights) Fits(r Weights) (bool, []v1.ResourceName)

Compare receiver to argument True if receiver is less than or equal to argument in every dimension

func (Weights) Max

func (w Weights) Max(r Weights)

Update receiver to max of receiver and argument in each dimension

func (Weights) QuotaFits

func (w Weights) QuotaFits(r Weights) (bool, []v1.ResourceName)

Compare receiver to argument True if receiver is less than or equal to argument in every dimension where argument is defined

func (Weights) QuotaSub

func (w Weights) QuotaSub(r Weights)

Subtract use from quota

func (Weights) Sub

func (w Weights) Sub(r Weights)

Subtract weights from receiver

type WeightsPair

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

A pair of Weights used to represent requests and limits for an object

func NewWeightsPair

func NewWeightsPair(requests Weights, limits Weights) *WeightsPair

Creates a new pair of weights

func NewWeightsPairForPod

func NewWeightsPairForPod(pod *v1.Pod) *WeightsPair

Create new WeightsPair for a pod

func (*WeightsPair) Add

func (w *WeightsPair) Add(r *WeightsPair)

Add pair of weights to receiver

func (*WeightsPair) Clone

func (w *WeightsPair) Clone() *WeightsPair

Clone a pair of weights

func (*WeightsPair) Fits

func (w *WeightsPair) Fits(r *WeightsPair) (bool, []v1.ResourceName)

Compare receiver to argument - True if both weights of receiver fit corresponding weights of argument. If False, return list of insufficient resource names

func (*WeightsPair) Max

func (w *WeightsPair) Max(r *WeightsPair)

Max of two pairs of weights

func (*WeightsPair) QuotaSub

func (w *WeightsPair) QuotaSub(r *WeightsPair)

Subtract pair of weights from receiver

func (*WeightsPair) String

func (w *WeightsPair) String() string

Jump to

Keyboard shortcuts

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