topology

package
v0.0.0-...-0eb2fac Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package topology contains an abstract interface for discovering topology segments for a storage backend and a specific implementation which does that based on the CSINodeDriver.TopologyKeys and the corresponding labels for the nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(added []*Segment, removed []*Segment)

type Informer

type Informer interface {
	// AddCallback ensures that the function is called each time
	// changes to the list of segments are detected. It also gets
	// called immediately when adding the callback and there are
	// already some known segments.
	AddCallback(cb Callback)

	// List returns all known segments, in no particular order.
	List() []*Segment

	// HasSynced returns true once all segments have been found.
	HasSynced() bool

	// RunWorker starts a worker to process queue.
	RunWorker(ctx context.Context)
}

Informer keeps a list of discovered topology segments and can notify one or more clients when it discovers changes. Segments are identified by their address and guaranteed to be unique.

func NewFixedNodeTopology

func NewFixedNodeTopology(segment *Segment) Informer

NewFixedNodeTopology creates topology informer for a driver with a fixed topology segment.

func NewNodeTopology

func NewNodeTopology(
	driverName string,
	client kubernetes.Interface,
	nodeInformer coreinformersv1.NodeInformer,
	csiNodeInformer storageinformersv1.CSINodeInformer,
	queue workqueue.RateLimitingInterface,
) Informer

NewNodeTopology returns an informer that synthesizes storage topology segments based on the accessible topology that each CSI driver node instance reports. See https://github.com/kubernetes/enhancements/tree/master/keps/sig-storage/1472-storage-capacity-tracking#with-central-controller for details.

type Mock

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

Mock simulates a driver installation on one or more nodes.

func NewMock

func NewMock(segments ...*Segment) *Mock

NewMock creates a new mocked topology informer with a certain set of pre-defined segments.

func (*Mock) AddCallback

func (mt *Mock) AddCallback(cb Callback)

func (*Mock) HasSynced

func (mt *Mock) HasSynced() bool

func (*Mock) List

func (mt *Mock) List() []*Segment

func (*Mock) Modify

func (mt *Mock) Modify(add, remove []*Segment)

Modify adds and/or removes segments.

func (*Mock) RunWorker

func (mt *Mock) RunWorker(ctx context.Context)

type Segment

type Segment []SegmentEntry

Segment represents a topology segment. Entries are always sorted by key and keys are unique. In contrast to a map, segments therefore can be compared efficiently. A nil segment matches no nodes in a cluster, an empty segment all of them.

func (Segment) Compare

func (s Segment) Compare(other Segment) int

Compare returns -1 if s is considered smaller than the other segment (less keys, keys and/or values smaller), 0 if equal and 1 otherwise.

func (Segment) GetLabelMap

func (s Segment) GetLabelMap() map[string]string

GetLabelMap returns nil if the Segment itself is nil, otherwise a map with all key/value pairs.

func (Segment) GetLabelSelector

func (s Segment) GetLabelSelector() *metav1.LabelSelector

GetLabelSelector returns a LabelSelector with the key/value entries as label match criteria.

func (Segment) Len

func (s Segment) Len() int

func (Segment) Less

func (s Segment) Less(i, j int) bool

func (*Segment) SimpleString

func (s *Segment) SimpleString() string

SimpleString only returns the content.

func (*Segment) String

func (s *Segment) String() string

String returns the address *and* the content of the segment; the address is how the segment is identified when used as a hash key.

func (Segment) Swap

func (s Segment) Swap(i, j int)

type SegmentEntry

type SegmentEntry struct {
	Key, Value string
}

SegmentEntry represents one topology key/value pair.

func (SegmentEntry) Compare

func (se SegmentEntry) Compare(other SegmentEntry) int

Compare returns -1 if se is considered smaller than the other segment entry (key or value smaller), 0 if equal and 1 otherwise.

func (SegmentEntry) String

func (se SegmentEntry) String() string

Jump to

Keyboard shortcuts

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