Documentation
¶
Index ¶
- type Node
- func (n *Node) AddPod(pod Pod)
- func (n *Node) GetPod(uid types.UID) (_ Pod, ok bool)
- func (n Node) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (n *Node) MigratablePods() iter.Seq2[types.UID, Pod]
- func (n *Node) OverBudget() bool
- func (n *Node) Pods() iter.Seq2[types.UID, Pod]
- func (n *Node) ReconcilePodReserved(pod *Pod) (done bool)
- func (n *Node) RemovePod(uid types.UID) (exists bool)
- func (n *Node) Speculatively(modify func(n *Node) (commit bool)) (committed bool)
- func (n *Node) Update(newState *Node) (changed bool)
- func (n *Node) UpdatePod(oldPod, newPod Pod) (changed bool)
- type NodeResourceField
- type NodeResources
- type Pod
- type PodResources
- type XactMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { Name string Labels *XactMap[string, string] CPU NodeResources[vmv1.MilliCPU] Mem NodeResources[api.Bytes] // contains filtered or unexported fields }
func NodeStateFromK8sObj ¶
func NodeStateFromParams ¶
func NodeStateFromParams( name string, totalCPU vmv1.MilliCPU, totalMem api.Bytes, watermarkFraction float64, labels map[string]string, ) *Node
NodeStateFromParams is a helper to construct a *Node, primarily for use in tests.
For practical usage, see NodeStateFromK8sObj.
func (*Node) GetPod ¶
GetPod returns a copy of the state for the Pod with the given UID, or false if no such Pod is present in the Node's state.
func (Node) MarshalLogObject ¶
func (n Node) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject implements zapcore.ObjectMarshaler so that Node can be used with zap.Object without emitting large lists of pods.
func (*Node) MigratablePods ¶
MigratablePods returns an iterator through the migratable pods on the node.
This method is provided as a specialized version of (*Node).Pods() in order to support more efficient look-ups when trying to balance nodes.
func (*Node) OverBudget ¶
OverBudget returns whether this node has more resources reserved than in total
func (*Node) ReconcilePodReserved ¶
ReconcilePodReserved will make all possible progress on updating the Pod's reserved resources based on the what's requested for the pod and what's available.
Currently, that's just updating the reserved resources to match what's requested (or, as much as is possible).
The new values of the Pod's resources will be left in the provided Pod.
This method will misbehave if the values of the Pod do not match the value of what's stored for that Pod in the node.
func (*Node) RemovePod ¶
RemovePod removes the pod from the node, given its UID, returning true iff the pod existed on the node.
Resources are updated as required.
func (*Node) Speculatively ¶
Speculatively allows attempting a modification to the node before deciding whether to actually commit that change.
Any of the fields of the node can be updated, including its pods.
func (*Node) Update ¶
Update sets the resource state of the node, corresponding to the changes in the totals present as part of newState.
GENERALLY there should be no change here, but if something happens, it's better to accept the change and continue rather than to operate on stale data.
type NodeResourceField ¶
type NodeResources ¶
type NodeResources[T constraints.Unsigned] struct { // Total is the total amount of T available on the node. // // This value does not change. Total T // Reserved is exactly equal to all Pods' <resource>.Reserved values. // // It SHOULD be less than or equal to Total, and - when live migration is enabled - we take // active measures to reduce it once it is above Watermark. // // Reserved can be greater than Total if: // * There is misbehavior between the autoscaler-agent and scheduler plugin; // * Eventual consistency causes us to operate on stale data; or // * Other pods are scheduled without going through our scheduler plugin Reserved T // Migrating is the amount of T that we expect will be removed by ongoing live migration. Migrating T // Watermark is the amount of T reserved to pods above which we attempt to reduce usage via // migration. // // This value does not change. Watermark T }
func (NodeResources[T]) Fields ¶
func (r NodeResources[T]) Fields() []NodeResourceField[T]
func (NodeResources[T]) UnmigratedAboveWatermark ¶
func (r NodeResources[T]) UnmigratedAboveWatermark() T
UnmigratedAboveWatermark returns the amount of T above Watermark that isn't already being migrated.
This method will panic if r.Migrating is greater than r.Reserved.
type Pod ¶
type Pod struct { util.NamespacedName UID types.UID CreatedAt time.Time // VirtualMachine, if not empty, gives the name of the VirtualMachine object that owns this Pod. VirtualMachine util.NamespacedName // Migratable is true if this Pod is owned by a VirtualMachine and it has the appropriate label // to enable automatic live migration. Migratable bool // AlwaysMigrate is true if this Pod is owned by a VirtualMachine and it has the (TESTING ONLY) // label to mark that this pod should be continuously migrated. AlwaysMigrate bool // Migrating is true iff there is a VirtualMachineMigration with this pod as the source. Migrating bool CPU PodResources[vmv1.MilliCPU] Mem PodResources[api.Bytes] }
func (Pod) BetterMigrationTargetThan ¶
BetterMigrationTargetThan returns <0 iff the pod is a better migration target than the 'other' pod.
func (Pod) MarshalLogObject ¶
func (p Pod) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject implements zapcore.ObjectMarshaler so that Pod can be used with zap.Object.
type PodResources ¶
type PodResources[T constraints.Unsigned] struct { // Reserved is the amount of T that has been set aside for usage by this Pod. // // For a regular pod, this is simply the sum of the resource requests for its containers, but // for a VM, it is equal to the last resources that the scheduler has approved for the // autoscaler-agent OR the CPU/Memory '.use' field, if that has not yet happened. Reserved T // Requested is the amount of T that the Pod would like to have available to it. // // For a regular Pod, this is exactly equal to Reserved. // // For a VM, this is equal to the last amount that the autoscaler-agent requested -- or if that // hasn't happened yet, simply Reserved. // // If Requested is ever less than Reserved, the scheduler is expected to immediately reduce // Reserved -- in effect, it's been given back resources that it previously set aside. Requested T // Factor is the smallest incremental change in T that can be allocated to the pod. // // For pods that aren't VMs, this should be set to zero, as it has no impact. Factor T }
PodResources is the extracted resources reserved and desired by the pod
type XactMap ¶
type XactMap[K comparable, V any] struct { // contains filtered or unexported fields }
XactMap is a map with support for transactions.
func NewXactMap ¶
func NewXactMap[K comparable, V any]() *XactMap[K, V]
func (*XactMap[K, V]) Commit ¶
func (m *XactMap[K, V]) Commit()
Commit propagates all changes from this local XactMap into its parent.
Afterwards, this map can continue to be used as normal, if you want.
func (*XactMap[K, V]) Delete ¶
func (m *XactMap[K, V]) Delete(key K)
Delete removes the key from the map, if it's present.
func (*XactMap[K, V]) Entries ¶
Entries returns an iterator over key-value pairs in the map.
Deleting elements from the map during iteration is always sound. They will not be visited later.
func (*XactMap[K, V]) Get ¶
Get returns the value for the key if it's present in the map, else (zero, false).
func (*XactMap[K, V]) NewTransaction ¶
NewTransaction creates a new XactMap that acts as a shallow copy of the parent -- any changes in the child will not affect the parent until a call to Commit(), if desired.
NOTE: Once you have already made some changes to the child, it is unsound to make changes to the parent and then continue using the child.