podpredicates

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoPredicate is returned when a predicate is not implemented.
	ErrNoPredicate = errors.New("no predicate found")

	// ErrAlreadyExists is returned when an entry already exists in registry.
	ErrAlreadyExists = errors.New("already exists")
)
View Source
var ErrInvalidResource = errors.New("invalid resource")

ErrInvalidResource error is used when an input resource is invalid.

Functions

func HugePageResourceName

func HugePageResourceName(pageSize resource.Quantity) v1.ResourceName

HugePageResourceName returns a ResourceName with the canonical hugepage prefix prepended for the specified page size. The page size is converted to its canonical representation.

func HugePageSizeFromResourceName

func HugePageSizeFromResourceName(name v1.ResourceName) (resource.Quantity, error)

HugePageSizeFromResourceName returns the page size for the specified huge page resource name. If the specified input is not a valid huge page resource name an error is returned.

func IsAttachableVolumeResourceName

func IsAttachableVolumeResourceName(name v1.ResourceName) bool

IsAttachableVolumeResourceName checks if the resource is an attachable volume.

func IsExtendedResourceName

func IsExtendedResourceName(name v1.ResourceName) bool

IsExtendedResourceName checks if the resource is an extended resource.

func IsHugePageResourceName

func IsHugePageResourceName(name v1.ResourceName) bool

IsHugePageResourceName returns true if the resource name has the huge page resource prefix.

func IsNativeResource

func IsNativeResource(name v1.ResourceName) bool

IsNativeResource returns true if the resource name is in the *kubernetes.io/ namespace. Partially-qualified (unprefixed) names are implicitly in the kubernetes.io/ namespace.

func IsPrefixedNativeResource

func IsPrefixedNativeResource(name v1.ResourceName) bool

IsPrefixedNativeResource returns true if the resource name is in the *kubernetes.io/ namespace.

func IsScalarResourceName

func IsScalarResourceName(name v1.ResourceName) bool

IsScalarResourceName checks if the resource is a scalar.

Types

type FilterPredicate

type FilterPredicate interface {
	Predicate
	Filter(ctx context.Context, hdl PodSetHandle, pod *v1.Pod, node *v1.Node) *framework.Status
}

FilterPredicate defines an interface to implement filter predicate handlers.

type Option

type Option func(o *predicateOption)

Option is the option used while creating the predicate handler.

func WithCallTimeout

func WithCallTimeout(timeout time.Duration) Option

WithCallTimeout is the grpc timeout to be used while accessing remotes with predicates.

func WithLogger

func WithLogger(log logr.Logger) Option

WithLogger defines the logger to be used with predicate handler.

func WithOutOfTreeRegistry

func WithOutOfTreeRegistry(registry Registry) Option

WithOutOfTreeRegistry is used to extend the built-in registry with a custom set.

func WithParallelism

func WithParallelism(p int) Option

WithParallelism defines the parallelism factor used while running the filter predicates.

type PodSetHandle

type PodSetHandle interface {
	// ClientSet returns a k8s clientset
	ClientSet() clientset.Interface

	// List returns a list of pods for the podset on the node
	List(context.Context, *v1.Node) ([]*v1.Pod, error)
}

PodSetHandle defines the interface for a podset used with predicate handler.

type Predicate

type Predicate interface {
	Name() string
}

Predicate defines an interface to implement predicate handlers.

type PredicateFactory

type PredicateFactory func(handle PredicateHandle) (Predicate, error)

PredicateFactory is the initialization routine used to create a new predicate instance.

type PredicateHandle

type PredicateHandle interface {
	CallTimeout() time.Duration
	Log(prefix string) logr.Logger
}

PredicateHandle defines a handle used while initializing the predicate.

type PredicateHandler

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

PredicateHandler is a framework used to run through all the predicates.

func New

func New(opts ...Option) (*PredicateHandler, error)

New is used to create a predicateHandler instance.

func (*PredicateHandler) FindNodesThatPassFilters

func (p *PredicateHandler) FindNodesThatPassFilters(parentCtx context.Context,
	podsetHandle PodSetHandle,
	pod *v1.Pod,
	eligibleNodes []*v1.Node,
) []*v1.Node

FindNodesThatPassFilters is used to find eligible nodes for a pod that pass all filters.

func (*PredicateHandler) RunFilterPredicates

func (p *PredicateHandler) RunFilterPredicates(ctx context.Context,
	handle PodSetHandle,
	pod *v1.Pod,
	node *v1.Node,
) *framework.Status

RunFilterPredicates is used to run all filter predicates to determine if the pod can be scheduled on the given node.

func (*PredicateHandler) RunScorePredicates

func (p *PredicateHandler) RunScorePredicates(ctx context.Context,
	handle PodSetHandle,
	pod *v1.Pod,
	nodes []*v1.Node,
) framework.NodeScoreList

RunScorePredicates is used to run all score predicates to determine the best node for the pod.

type Registry

type Registry map[string]PredicateFactory

Registry contains a map of predicates to their initialization function.

func NewInTreeRegistry

func NewInTreeRegistry() Registry

NewInTreeRegistry is used to instantiate a built-in registry.

func (Registry) Add

func (r Registry) Add(name string, factory PredicateFactory) error

Add is used to add a predicate with its init function to the registry.

func (Registry) Merge

func (r Registry) Merge(newr Registry) error

Merge is used to merge new registry into the current registry.

type Resource

type Resource struct {
	MilliCPU         int64
	Memory           int64
	EphemeralStorage int64
	// We store allowedPodNumber (which is Node.Status.Allocatable.Pods().Value())
	// explicitly as int, to avoid conversions and improve performance.
	AllowedPodNumber int
	// ScalarResources
	ScalarResources map[v1.ResourceName]int64
}

Resource is a collection of compute resource.

func NewResource

func NewResource(rl v1.ResourceList) *Resource

NewResource creates a Resource from ResourceList.

func (*Resource) Add

func (r *Resource) Add(rl v1.ResourceList)

Add adds ResourceList into Resource.

func (*Resource) AddScalar

func (r *Resource) AddScalar(name v1.ResourceName, quantity int64)

AddScalar adds a resource by a scalar value of this resource.

func (*Resource) Clone

func (r *Resource) Clone() *Resource

Clone returns a copy of this resource.

func (*Resource) ResourceList

func (r *Resource) ResourceList() v1.ResourceList

ResourceList returns a resource list of this resource.

func (*Resource) SetMaxResource

func (r *Resource) SetMaxResource(rl v1.ResourceList)

SetMaxResource compares with ResourceList and takes max value for each Resource.

func (*Resource) SetScalar

func (r *Resource) SetScalar(name v1.ResourceName, quantity int64)

SetScalar sets a resource by a scalar value of this resource.

type ScorePredicate

type ScorePredicate interface {
	Predicate
	Score(ctx context.Context, hdl PodSetHandle, pod *v1.Pod, node *v1.Node) (int64, *framework.Status)
}

ScorePredicate defines an interface to implement scoring a node assignment for the pod.

Jump to

Keyboard shortcuts

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