capacity

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: 28 Imported by: 0

Documentation

Overview

Package capacity contains the code which controls the CSIStorageCapacity objects owned by the external-provisioner.

Package capacity contains the code which controls the CSIStorageCapacity objects owned by the external-provisioner.

Package capacity contains the code which controls the CSIStorageCapacity objects owned by the external-provisioner.

Index

Constants

View Source
const (
	DriverNameLabel = "csi.storage.k8s.io/drivername"
	ManagedByLabel  = "csi.storage.k8s.io/managed-by"
)

Variables

This section is empty.

Functions

Types

type CSICapacityClient

type CSICapacityClient interface {
	GetCapacity(ctx context.Context, in *csi.GetCapacityRequest, opts ...grpc.CallOption) (*csi.GetCapacityResponse, error)
}

CSICapacityClient is the relevant subset of csi.ControllerClient.

type CSIStorageCapacityFactory

type CSIStorageCapacityFactory func(namespace string) CSIStorageCapacityInterface

CSIStorageCapacityFactory corresponds to StorageV1().CSIStorageCapacities but returns just what we need.

func NewV1ClientFactory

func NewV1ClientFactory(clientSet kubernetes.Interface) CSIStorageCapacityFactory

func NewV1beta1ClientFactory

func NewV1beta1ClientFactory(clientSet kubernetes.Interface) CSIStorageCapacityFactory

type CSIStorageCapacityInterface

type CSIStorageCapacityInterface interface {
	Create(ctx context.Context, cSIStorageCapacity *storagev1.CSIStorageCapacity, opts metav1.CreateOptions) (*storagev1.CSIStorageCapacity, error)
	Update(ctx context.Context, cSIStorageCapacity *storagev1.CSIStorageCapacity, opts metav1.UpdateOptions) (*storagev1.CSIStorageCapacity, error)
	Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
}

CSIStorageCapacityInterface is a subset of the client-go interface for v1.CSIStorageCapacity.

type Controller

type Controller struct {
	metrics.BaseStableCollector
	// contains filtered or unexported fields
}

Controller creates and updates CSIStorageCapacity objects. It deletes those which are no longer needed because their storage class or topology segment are gone. The controller only manages those CSIStorageCapacity objects that are owned by a certain entity.

The controller maintains a set of topology segments (= NodeSelector pointers). Work items are a combination of such a pointer and a pointer to a storage class. These keys are mapped to the corresponding CSIStorageCapacity object, if one exists.

When processing a work item, the controller first checks whether the topology segment and storage class still exist. If not, the CSIStorageCapacity object gets deleted. Otherwise, it gets updated or created.

New work items are queued for processing when the reconiliation loop finds differences, periodically (to refresh existing items) and when capacity is expected to have changed.

The work queue is also used to delete duplicate CSIStorageCapacity objects, i.e. those that for some reason have the same topology segment and storage class name as some other object. That should never happen, but the controller is prepared to clean that up, just in case.

func NewCentralCapacityController

func NewCentralCapacityController(
	csiController CSICapacityClient,
	driverName string,
	clientFactory CSIStorageCapacityFactory,
	queue workqueue.RateLimitingInterface,
	owner *metav1.OwnerReference,
	managedByID string,
	ownerNamespace string,
	topologyInformer topology.Informer,
	scInformer storageinformersv1.StorageClassInformer,
	cInformer storageinformersv1.CSIStorageCapacityInformer,
	pollPeriod time.Duration,
	immediateBinding bool,
	timeout time.Duration,
) *Controller

NewController creates a new controller for CSIStorageCapacity objects. It implements metrics.StableCollector and thus can be registered in a registry.

func (*Controller) CollectWithStability

func (c *Controller) CollectWithStability(ch chan<- metrics.Metric)

CollectWithStability implements the metrics.StableCollector interface.

func (*Controller) DescribeWithStability

func (c *Controller) DescribeWithStability(ch chan<- *metrics.Desc)

DescribeWithStability implements the metrics.StableCollector interface.

func (*Controller) Run

func (c *Controller) Run(ctx context.Context, threadiness int)

Run is a main Controller handler

Directories

Path Synopsis
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.
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.

Jump to

Keyboard shortcuts

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