Documentation ¶
Index ¶
- Variables
- func InitializeClusterSnapshotOrDie(t *testing.T, snapshot ClusterSnapshot, nodes []*apiv1.Node, pods []*apiv1.Pod)
- func WithForkedSnapshot(snapshot ClusterSnapshot, f func() (bool, error)) (error, error)
- type BasicClusterSnapshot
- func (snapshot *BasicClusterSnapshot) AddNode(node *apiv1.Node) error
- func (snapshot *BasicClusterSnapshot) AddNodeWithPods(node *apiv1.Node, pods []*apiv1.Pod) error
- func (snapshot *BasicClusterSnapshot) AddNodes(nodes []*apiv1.Node) error
- func (snapshot *BasicClusterSnapshot) AddPod(pod *apiv1.Pod, nodeName string) error
- func (snapshot *BasicClusterSnapshot) Clear()
- func (snapshot *BasicClusterSnapshot) Commit() error
- func (snapshot *BasicClusterSnapshot) Fork()
- func (snapshot *BasicClusterSnapshot) IsPVCUsedByPods(key string) bool
- func (snapshot *BasicClusterSnapshot) NodeInfos() schedulerframework.NodeInfoLister
- func (snapshot *BasicClusterSnapshot) RemoveNode(nodeName string) error
- func (snapshot *BasicClusterSnapshot) RemovePod(namespace, podName, nodeName string) error
- func (snapshot *BasicClusterSnapshot) Revert()
- func (snapshot *BasicClusterSnapshot) StorageInfos() schedulerframework.StorageInfoLister
- type ClusterSnapshot
- type DeltaClusterSnapshot
- func (snapshot *DeltaClusterSnapshot) AddNode(node *apiv1.Node) error
- func (snapshot *DeltaClusterSnapshot) AddNodeWithPods(node *apiv1.Node, pods []*apiv1.Pod) error
- func (snapshot *DeltaClusterSnapshot) AddNodes(nodes []*apiv1.Node) error
- func (snapshot *DeltaClusterSnapshot) AddPod(pod *apiv1.Pod, nodeName string) error
- func (snapshot *DeltaClusterSnapshot) Clear()
- func (snapshot *DeltaClusterSnapshot) Commit() error
- func (snapshot *DeltaClusterSnapshot) Fork()
- func (snapshot *DeltaClusterSnapshot) IsPVCUsedByPods(key string) bool
- func (snapshot *DeltaClusterSnapshot) NodeInfos() schedulerframework.NodeInfoLister
- func (snapshot *DeltaClusterSnapshot) RemoveNode(nodeName string) error
- func (snapshot *DeltaClusterSnapshot) RemovePod(namespace, podName, nodeName string) error
- func (snapshot *DeltaClusterSnapshot) Revert()
- func (snapshot *DeltaClusterSnapshot) StorageInfos() schedulerframework.StorageInfoLister
Constants ¶
This section is empty.
Variables ¶
var ErrNodeNotFound = errors.New("node not found")
ErrNodeNotFound means that a node wasn't found in the snapshot.
Functions ¶
func InitializeClusterSnapshotOrDie ¶
func InitializeClusterSnapshotOrDie( t *testing.T, snapshot ClusterSnapshot, nodes []*apiv1.Node, pods []*apiv1.Pod)
InitializeClusterSnapshotOrDie clears cluster snapshot and then initializes it with given set of nodes and pods. Both Spec.NodeName and Status.NominatedNodeName are used when simulating scheduling pods.
func WithForkedSnapshot ¶
func WithForkedSnapshot(snapshot ClusterSnapshot, f func() (bool, error)) (error, error)
WithForkedSnapshot is a helper function for snapshot that makes sure all Fork() calls are closed with Commit() or Revert() calls. The function return (error, error) pair. The first error comes from the passed function, the second error indicate the success of the function itself.
Types ¶
type BasicClusterSnapshot ¶
type BasicClusterSnapshot struct {
// contains filtered or unexported fields
}
BasicClusterSnapshot is simple, reference implementation of ClusterSnapshot. It is inefficient. But hopefully bug-free and good for initial testing.
func NewBasicClusterSnapshot ¶
func NewBasicClusterSnapshot() *BasicClusterSnapshot
NewBasicClusterSnapshot creates instances of BasicClusterSnapshot.
func (*BasicClusterSnapshot) AddNode ¶
func (snapshot *BasicClusterSnapshot) AddNode(node *apiv1.Node) error
AddNode adds node to the snapshot.
func (*BasicClusterSnapshot) AddNodeWithPods ¶
AddNodeWithPods adds a node and set of pods to be scheduled to this node to the snapshot.
func (*BasicClusterSnapshot) AddNodes ¶
func (snapshot *BasicClusterSnapshot) AddNodes(nodes []*apiv1.Node) error
AddNodes adds nodes in batch to the snapshot.
func (*BasicClusterSnapshot) AddPod ¶
func (snapshot *BasicClusterSnapshot) AddPod(pod *apiv1.Pod, nodeName string) error
AddPod adds pod to the snapshot and schedules it to given node.
func (*BasicClusterSnapshot) Clear ¶
func (snapshot *BasicClusterSnapshot) Clear()
Clear reset cluster snapshot to empty, unforked state
func (*BasicClusterSnapshot) Commit ¶
func (snapshot *BasicClusterSnapshot) Commit() error
Commit commits changes done after forking.
func (*BasicClusterSnapshot) Fork ¶
func (snapshot *BasicClusterSnapshot) Fork()
Fork creates a fork of snapshot state. All modifications can later be reverted to moment of forking via Revert()
func (*BasicClusterSnapshot) IsPVCUsedByPods ¶
func (snapshot *BasicClusterSnapshot) IsPVCUsedByPods(key string) bool
IsPVCUsedByPods returns if the pvc is used by any pod
func (*BasicClusterSnapshot) NodeInfos ¶
func (snapshot *BasicClusterSnapshot) NodeInfos() schedulerframework.NodeInfoLister
NodeInfos exposes snapshot as NodeInfoLister.
func (*BasicClusterSnapshot) RemoveNode ¶
func (snapshot *BasicClusterSnapshot) RemoveNode(nodeName string) error
RemoveNode removes nodes (and pods scheduled to it) from the snapshot.
func (*BasicClusterSnapshot) RemovePod ¶
func (snapshot *BasicClusterSnapshot) RemovePod(namespace, podName, nodeName string) error
RemovePod removes pod from the snapshot.
func (*BasicClusterSnapshot) Revert ¶
func (snapshot *BasicClusterSnapshot) Revert()
Revert reverts snapshot state to moment of forking.
func (*BasicClusterSnapshot) StorageInfos ¶
func (snapshot *BasicClusterSnapshot) StorageInfos() schedulerframework.StorageInfoLister
StorageInfos exposes snapshot as StorageInfoLister.
type ClusterSnapshot ¶
type ClusterSnapshot interface { schedulerframework.SharedLister // AddNode adds node to the snapshot. AddNode(node *apiv1.Node) error // AddNodes adds nodes to the snapshot. AddNodes(nodes []*apiv1.Node) error // RemoveNode removes nodes (and pods scheduled to it) from the snapshot. RemoveNode(nodeName string) error // AddPod adds pod to the snapshot and schedules it to given node. AddPod(pod *apiv1.Pod, nodeName string) error // RemovePod removes pod from the snapshot. RemovePod(namespace string, podName string, nodeName string) error // AddNodeWithPods adds a node and set of pods to be scheduled to this node to the snapshot. AddNodeWithPods(node *apiv1.Node, pods []*apiv1.Pod) error // IsPVCUsedByPods returns if the pvc is used by any pod, key = <namespace>/<pvc_name> IsPVCUsedByPods(key string) bool // Fork creates a fork of snapshot state. All modifications can later be reverted to moment of forking via Revert(). // Use WithForkedSnapshot() helper function instead if possible. Fork() // Revert reverts snapshot state to moment of forking. Revert() // Commit commits changes done after forking. Commit() error // Clear reset cluster snapshot to empty, unforked state. Clear() }
ClusterSnapshot is abstraction of cluster state used for predicate simulations. It exposes mutation methods and can be viewed as scheduler's SharedLister.
type DeltaClusterSnapshot ¶
type DeltaClusterSnapshot struct {
// contains filtered or unexported fields
}
DeltaClusterSnapshot is an implementation of ClusterSnapshot optimized for typical Cluster Autoscaler usage - (fork, add stuff, revert), repeated many times per loop.
Complexity of some notable operations:
fork - O(1) revert - O(1) commit - O(n) list all pods (no filtering) - O(n), cached list all pods (with filtering) - O(n) list node infos - O(n), cached
Watch out for:
node deletions, pod additions & deletions - invalidates cache of current snapshot (when forked affects delta, but not base.) pod affinity - causes scheduler framework to list pods with non-empty selector, so basic caching doesn't help.
func NewDeltaClusterSnapshot ¶
func NewDeltaClusterSnapshot() *DeltaClusterSnapshot
NewDeltaClusterSnapshot creates instances of DeltaClusterSnapshot.
func (*DeltaClusterSnapshot) AddNode ¶
func (snapshot *DeltaClusterSnapshot) AddNode(node *apiv1.Node) error
AddNode adds node to the snapshot.
func (*DeltaClusterSnapshot) AddNodeWithPods ¶
AddNodeWithPods adds a node and set of pods to be scheduled to this node to the snapshot.
func (*DeltaClusterSnapshot) AddNodes ¶
func (snapshot *DeltaClusterSnapshot) AddNodes(nodes []*apiv1.Node) error
AddNodes adds nodes in batch to the snapshot.
func (*DeltaClusterSnapshot) AddPod ¶
func (snapshot *DeltaClusterSnapshot) AddPod(pod *apiv1.Pod, nodeName string) error
AddPod adds pod to the snapshot and schedules it to given node.
func (*DeltaClusterSnapshot) Clear ¶
func (snapshot *DeltaClusterSnapshot) Clear()
Clear reset cluster snapshot to empty, unforked state Time: O(1)
func (*DeltaClusterSnapshot) Commit ¶
func (snapshot *DeltaClusterSnapshot) Commit() error
Commit commits changes done after forking. Time: O(n), where n = size of delta (number of nodes added, modified or deleted since forking)
func (*DeltaClusterSnapshot) Fork ¶
func (snapshot *DeltaClusterSnapshot) Fork()
Fork creates a fork of snapshot state. All modifications can later be reverted to moment of forking via Revert() Time: O(1)
func (*DeltaClusterSnapshot) IsPVCUsedByPods ¶
func (snapshot *DeltaClusterSnapshot) IsPVCUsedByPods(key string) bool
IsPVCUsedByPods returns if the pvc is used by any pod
func (*DeltaClusterSnapshot) NodeInfos ¶
func (snapshot *DeltaClusterSnapshot) NodeInfos() schedulerframework.NodeInfoLister
NodeInfos returns node lister.
func (*DeltaClusterSnapshot) RemoveNode ¶
func (snapshot *DeltaClusterSnapshot) RemoveNode(nodeName string) error
RemoveNode removes nodes (and pods scheduled to it) from the snapshot.
func (*DeltaClusterSnapshot) RemovePod ¶
func (snapshot *DeltaClusterSnapshot) RemovePod(namespace, podName, nodeName string) error
RemovePod removes pod from the snapshot.
func (*DeltaClusterSnapshot) Revert ¶
func (snapshot *DeltaClusterSnapshot) Revert()
Revert reverts snapshot state to moment of forking. Time: O(1)
func (*DeltaClusterSnapshot) StorageInfos ¶
func (snapshot *DeltaClusterSnapshot) StorageInfos() schedulerframework.StorageInfoLister
StorageInfos returns storage lister