clustersnapshot

package
v0.0.0-...-fdc6b19 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNodeNotFound = errors.New("node not found")

ErrNodeNotFound means that a node wasn't found in the snapshot.

Functions

func InitializeClusterSnapshotOrDie

func InitializeClusterSnapshotOrDie(
	snapshot ClusterSnapshot,
	nodes []apiv1.Node,
	pods []apiv1.Pod)

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

func (snapshot *BasicClusterSnapshot) AddNodeWithPods(node *apiv1.Node, pods []*apiv1.Pod) error

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

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

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.

Jump to

Keyboard shortcuts

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