framework

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBindAllHostIP = "0.0.0.0"

DefaultBindAllHostIP defines the default ip address used to bind to all host.

Variables

This section is empty.

Functions

func GetNamespacedName

func GetNamespacedName(namespace, name string) string

GetNamespacedName returns the string format of a namespaced resource name.

func GetPodKey

func GetPodKey(pod *corev1.Pod) (string, error)

GetPodKey returns the string key of a pod.

Types

type ActionType

type ActionType int64

ActionType is an integer to represent one type of resource change. Different ActionTypes can be bit-wised to compose new semantics.

const (
	Add    ActionType = 1 << iota // 1
	Delete                        // 10
	// UpdateNodeXYZ is only applicable for Node events.
	UpdateNodeAllocatable // 100
	UpdateNodeLabel       // 1000
	UpdateNodeTaint       // 10000
	UpdateNodeCondition   // 100000

	All ActionType = 1<<iota - 1 // 111111

	// Use the general Update type if you don't either know or care the specific sub-Update type to use.
	Update = UpdateNodeAllocatable | UpdateNodeLabel | UpdateNodeTaint | UpdateNodeCondition
)

Constants for ActionTypes.

type AffinityTerm

type AffinityTerm struct {
	//nolint:staticcheck
	// disable `deprecation` check for lifted code.
	Namespaces        sets.String
	Selector          labels.Selector
	TopologyKey       string
	NamespaceSelector labels.Selector
}

AffinityTerm is a processed version of corev1.PodAffinityTerm.

func (*AffinityTerm) Matches

func (at *AffinityTerm) Matches(pod *corev1.Pod, nsLabels labels.Set) bool

Matches returns true if the pod matches the label selector and namespaces or namespace selector.

type ClusterEvent

type ClusterEvent struct {
	Resource   GVK
	ActionType ActionType
	Label      string
}

ClusterEvent abstracts how a system resource's state gets changed. Resource represents the standard API resources such as Pod, Node, etc. ActionType denotes the specific change such as Add, Update or Delete.

func (ClusterEvent) IsWildCard

func (ce ClusterEvent) IsWildCard() bool

IsWildCard returns true if ClusterEvent follows WildCard semantics

type GVK

type GVK string

GVK is short for group/version/kind, which can uniquely represent a particular API resource.

const (
	Pod                   GVK = "Pod"
	Node                  GVK = "Node"
	PersistentVolume      GVK = "PersistentVolume"
	PersistentVolumeClaim GVK = "PersistentVolumeClaim"
	PodScheduling         GVK = "PodScheduling"
	ResourceClaim         GVK = "ResourceClaim"
	StorageClass          GVK = "storage.k8s.io/StorageClass"
	CSINode               GVK = "storage.k8s.io/CSINode"
	CSIDriver             GVK = "storage.k8s.io/CSIDriver"
	CSIStorageCapacity    GVK = "storage.k8s.io/CSIStorageCapacity"
	WildCard              GVK = "*"
)

Constants for GVKs.

type HostPortInfo

type HostPortInfo map[string]map[ProtocolPort]struct{}

HostPortInfo stores mapping from ip to a set of ProtocolPort

func (HostPortInfo) Add

func (h HostPortInfo) Add(ip, protocol string, port int32)

Add adds (ip, protocol, port) to HostPortInfo

func (HostPortInfo) CheckConflict

func (h HostPortInfo) CheckConflict(ip, protocol string, port int32) bool

CheckConflict checks if the input (ip, protocol, port) conflicts with the existing ones in HostPortInfo.

func (HostPortInfo) Len

func (h HostPortInfo) Len() int

Len returns the total number of (ip, protocol, port) tuple in HostPortInfo

func (HostPortInfo) Remove

func (h HostPortInfo) Remove(ip, protocol string, port int32)

Remove removes (ip, protocol, port) from HostPortInfo

type ImageStateSummary

type ImageStateSummary struct {
	// Size of the image
	Size int64
	// Used to track how many nodes have this image
	NumNodes int
}

ImageStateSummary provides summarized information about the state of an image.

type NodeInfo

type NodeInfo struct {

	// Pods running on the node.
	Pods []*PodInfo

	// The subset of pods with affinity.
	PodsWithAffinity []*PodInfo

	// The subset of pods with required anti-affinity.
	PodsWithRequiredAntiAffinity []*PodInfo

	// Ports allocated on the node.
	UsedPorts HostPortInfo

	// Total requested resources of all pods on this node. This includes assumed
	// pods, which scheduler has sent for binding, but may not be scheduled yet.
	Requested *util.Resource
	// Total requested resources of all pods on this node with a minimum value
	// applied to each container's CPU and memory requests. This does not reflect
	// the actual resource requests for this node, but is used to avoid scheduling
	// many zero-request pods onto one node.
	NonZeroRequested *util.Resource
	// We store allocatedResources (which is Node.Status.Allocatable.*) explicitly
	// as int64, to avoid conversions and accessing map.
	Allocatable *util.Resource

	// ImageStates holds the entry of an image if and only if this image is on the node. The entry can be used for
	// checking an image's existence and advanced usage (e.g., image locality scheduling policy) based on the image
	// state information.
	ImageStates map[string]*ImageStateSummary

	// PVCRefCounts contains a mapping of PVC names to the number of pods on the node using it.
	// Keys are in the format "namespace/name".
	PVCRefCounts map[string]int

	// Whenever NodeInfo changes, generation is bumped.
	// This is used to avoid cloning it if the object didn't change.
	Generation int64
	// contains filtered or unexported fields
}

NodeInfo is node level aggregated information.

func NewNodeInfo

func NewNodeInfo(pods ...*corev1.Pod) *NodeInfo

NewNodeInfo returns a ready to use empty NodeInfo object. If any pods are given in arguments, their information will be aggregated in the returned object.

func (*NodeInfo) AddPod

func (n *NodeInfo) AddPod(pod *corev1.Pod)

AddPod is a wrapper around AddPodInfo.

func (*NodeInfo) AddPodInfo

func (n *NodeInfo) AddPodInfo(podInfo *PodInfo)

AddPodInfo adds pod information to this NodeInfo. Consider using this instead of AddPod if a PodInfo is already computed.

func (*NodeInfo) Clone

func (n *NodeInfo) Clone() *NodeInfo

Clone returns a copy of this node.

func (*NodeInfo) Node

func (n *NodeInfo) Node() *corev1.Node

Node returns overall information about this node.

func (*NodeInfo) RemoveNode

func (n *NodeInfo) RemoveNode()

RemoveNode removes the node object, leaving all other tracking information.

func (*NodeInfo) RemovePod

func (n *NodeInfo) RemovePod(pod *corev1.Pod) error

RemovePod subtracts pod information from this NodeInfo.

func (*NodeInfo) SetNode

func (n *NodeInfo) SetNode(node *corev1.Node)

SetNode sets the overall node information.

func (*NodeInfo) String

func (n *NodeInfo) String() string

String returns representation of human readable format of this NodeInfo.

type NodeInfoLister

type NodeInfoLister interface {
	// List returns the list of NodeInfos.
	List() ([]*NodeInfo, error)
	// HavePodsWithAffinityList returns the list of NodeInfos of nodes with pods with affinity terms.
	HavePodsWithAffinityList() ([]*NodeInfo, error)
	// HavePodsWithRequiredAntiAffinityList returns the list of NodeInfos of nodes with pods with required anti-affinity terms.
	HavePodsWithRequiredAntiAffinityList() ([]*NodeInfo, error)
	// Get returns the NodeInfo of the given node name.
	Get(nodeName string) (*NodeInfo, error)
}

NodeInfoLister interface represents anything that can list/get NodeInfo objects from node name.

type PodInfo

type PodInfo struct {
	Pod                        *corev1.Pod
	RequiredAffinityTerms      []AffinityTerm
	RequiredAntiAffinityTerms  []AffinityTerm
	PreferredAffinityTerms     []WeightedAffinityTerm
	PreferredAntiAffinityTerms []WeightedAffinityTerm
}

PodInfo is a wrapper to a Pod with additional pre-computed information to accelerate processing. This information is typically immutable (e.g., pre-processed inter-pod affinity selectors).

func NewPodInfo

func NewPodInfo(pod *corev1.Pod) (*PodInfo, error)

NewPodInfo returns a new PodInfo.

func (*PodInfo) DeepCopy

func (pi *PodInfo) DeepCopy() *PodInfo

DeepCopy returns a deep copy of the PodInfo object.

func (*PodInfo) Update

func (pi *PodInfo) Update(pod *corev1.Pod) error

Update creates a full new PodInfo by default. And only updates the pod when the PodInfo has been instantiated and the passed pod is the exact same one as the original pod.

type ProtocolPort

type ProtocolPort struct {
	Protocol string
	Port     int32
}

ProtocolPort represents a protocol port pair, e.g. tcp:80.

func NewProtocolPort

func NewProtocolPort(protocol string, port int32) *ProtocolPort

NewProtocolPort creates a ProtocolPort instance.

type QueuedPodInfo

type QueuedPodInfo struct {
	*PodInfo
	// The time pod added to the scheduling queue.
	Timestamp time.Time
	// Number of schedule attempts before successfully scheduled.
	// It's used to record the # attempts metric.
	Attempts int
	// The time when the pod is added to the queue for the first time. The pod may be added
	// back to the queue multiple times before it's successfully scheduled.
	// It shouldn't be updated once initialized. It's used to record the e2e scheduling
	// latency for a pod.
	InitialAttemptTimestamp time.Time
	// If a Pod failed in a scheduling cycle, record the plugin names it failed by.
	//nolint:staticcheck
	// disable `deprecation` check for lifted code.
	UnschedulablePlugins sets.String
	// Whether the Pod is scheduling gated (by PreEnqueuePlugins) or not.
	Gated bool
}

QueuedPodInfo is a Pod wrapper with additional information related to the pod's status in the scheduling queue, such as the timestamp when it's added to the queue.

func (*QueuedPodInfo) DeepCopy

func (pqi *QueuedPodInfo) DeepCopy() *QueuedPodInfo

DeepCopy returns a deep copy of the QueuedPodInfo object.

type SharedLister

type SharedLister interface {
	NodeInfos() NodeInfoLister
	StorageInfos() StorageInfoLister
}

SharedLister groups scheduler-specific listers.

type StorageInfoLister

type StorageInfoLister interface {
	// IsPVCUsedByPods returns true/false on whether the PVC is used by one or more scheduled pods,
	// keyed in the format "namespace/name".
	IsPVCUsedByPods(key string) bool
}

StorageInfoLister interface represents anything that handles storage-related operations and resources.

type WeightedAffinityTerm

type WeightedAffinityTerm struct {
	AffinityTerm
	Weight int32
}

WeightedAffinityTerm is a "processed" representation of corev1.WeightedAffinityTerm.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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