capacityplanner

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const AcSizeMinThresholdBytes = int64(util.MBYTE) // 1MB

AcSizeMinThresholdBytes means that if AC size becomes lower then AcSizeMinThresholdBytes that AC should be deleted

View Source
const DefaultPESize = 4 * int64(util.MBYTE)

DefaultPESize is the default extent size we should align with TODO: use non default PE size - https://github.com/dell/csi-baremetal/issues/85

View Source
const LvgDefaultMetadataSize = int64(util.MBYTE) // 1MB

LvgDefaultMetadataSize is additional cost for new VG we should consider.

Variables

This section is empty.

Functions

func AlignSizeByMB added in v1.3.0

func AlignSizeByMB(size int64) int64

AlignSizeByMB make size aligned with MB

func AlignSizeByPE

func AlignSizeByPE(size int64) int64

AlignSizeByPE make size aligned with default PE TODO: use non default PE size - https://github.com/dell/csi-baremetal/issues/85

func FilterACList

func FilterACList(
	acs []accrd.AvailableCapacity, filter func(ac accrd.AvailableCapacity) bool) []accrd.AvailableCapacity

FilterACList filter for AC list

func FilterACRList

FilterACRList filter for ACR list

func SubtractLVMMetadataSize

func SubtractLVMMetadataSize(size int64) int64

SubtractLVMMetadataSize subtracts LVM metadata size from raw drive size

Types

type ACMap

type ACMap map[string]*accrd.AvailableCapacity

ACMap AC.Name to AC mapping

type ACNameToACRNamesMap

type ACNameToACRNamesMap map[string][]string

ACNameToACRNamesMap AC name to ACR names mapping

type ACRMap

ACRMap ACR.Name to ACR mapping

type ACRReader

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

ACRReader read ACR from kubernetes API

func NewACRReader

func NewACRReader(client *k8s.KubeClient, logger *logrus.Entry, cached bool) *ACRReader

NewACRReader returns instance of ACReader

func (*ACRReader) ReadReservation

func (acr *ACRReader) ReadReservation(ctx context.Context, name string) (*acrcrd.AvailableCapacityReservation, error)

ReadReservation returns ACR which was read from kubernetes API

func (*ACRReader) ReadReservations

func (acr *ACRReader) ReadReservations(ctx context.Context) ([]acrcrd.AvailableCapacityReservation, error)

ReadReservations returns ACR list which was read from kubernetes API

type ACReader

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

ACReader read AC from kubernetes API

func NewACReader

func NewACReader(client *k8s.KubeClient, logger *logrus.Entry, cached bool) *ACReader

NewACReader returns instance of ACReader

func (*ACReader) ReadCapacity

func (acr *ACReader) ReadCapacity(ctx context.Context) ([]accrd.AvailableCapacity, error)

ReadCapacity returns AC list which was read from kubernetes API or from cache

type CapacityManager

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

CapacityManager provides placing plan for volumes

func NewCapacityManager

func NewCapacityManager(logger *logrus.Entry, capReader CapacityReader,
	resReader ReservationReader, sequentialLVGReservation bool) *CapacityManager

NewCapacityManager return new instance of CapacityManager

func (*CapacityManager) PlanVolumesPlacing

func (cm *CapacityManager) PlanVolumesPlacing(ctx context.Context, volumes []*genV1.Volume, nodes []string) (*VolumesPlacingPlan, error)

PlanVolumesPlacing build placing plan for volumes

type CapacityManagerBuilder

type CapacityManagerBuilder interface {
	// GetCapacityManager returns CapacityManager
	GetCapacityManager(logger *logrus.Entry,
		capReader CapacityReader, resReader ReservationReader) CapacityPlaner
}

CapacityManagerBuilder interface for capacity managers creation

type CapacityPlaner

type CapacityPlaner interface {
	// PlanVolumesPlacing plan volumes placing on nodes
	PlanVolumesPlacing(ctx context.Context, volumes []*genV1.Volume, nodes []string) (*VolumesPlacingPlan, error)
}

CapacityPlaner describes interface for volumes placing planing

type CapacityReader

type CapacityReader interface {
	// ReadCapacity read capacity
	ReadCapacity(ctx context.Context) ([]accrd.AvailableCapacity, error)
}

CapacityReader methods to read available capacity

type CapacityReaderMock

type CapacityReaderMock struct {
	mock.Mock
}

CapacityReaderMock is a mock implementation of CapacityReader interface for test purposes

func (*CapacityReaderMock) ReadCapacity

func (cr *CapacityReaderMock) ReadCapacity(ctx context.Context) ([]accrd.AvailableCapacity, error)

ReadCapacity is a mock implementation of CapacityReader

type DefaultCapacityManagerBuilder

type DefaultCapacityManagerBuilder struct {
	SequentialLVGReservation bool
}

DefaultCapacityManagerBuilder is a builder for default CapacityManagers

func (*DefaultCapacityManagerBuilder) GetCapacityManager

func (dcmb *DefaultCapacityManagerBuilder) GetCapacityManager(
	logger *logrus.Entry, capReader CapacityReader, resReader ReservationReader) CapacityPlaner

GetCapacityManager returns default implementation of CapacityManager

type MockCapacityManagerBuilder

type MockCapacityManagerBuilder struct {
	Manager CapacityPlaner
}

MockCapacityManagerBuilder is a builder for CapacityManagers which return mocked versions of managers

func (*MockCapacityManagerBuilder) GetCapacityManager

func (mcb *MockCapacityManagerBuilder) GetCapacityManager(logger *logrus.Entry, capReader CapacityReader,
	resReader ReservationReader) CapacityPlaner

GetCapacityManager returns mock implementation of CapacityManager

func (*MockCapacityManagerBuilder) GetReservedCapacityManager

func (mcb *MockCapacityManagerBuilder) GetReservedCapacityManager(logger *logrus.Entry,
	capReader CapacityReader, resReader ReservationReader) CapacityPlaner

GetReservedCapacityManager returns mock implementation of ReservedCapacityManager

type NodeCapacityMap

type NodeCapacityMap map[string]ACMap

NodeCapacityMap NodeID to ACMap mapping

type PlannerMock

type PlannerMock struct {
	mock.Mock
}

PlannerMock is a mock implementation of CapacityManager

func (*PlannerMock) PlanVolumesPlacing

func (cr *PlannerMock) PlanVolumesPlacing(ctx context.Context, volumes []*genV1.Volume, nodes []string) (*VolumesPlacingPlan, error)

PlanVolumesPlacing mock implementation of PlanVolumesPlacing

type ReservationFilter

type ReservationFilter struct{}

ReservationFilter helper for working with ACR based reservations

func NewReservationFilter

func NewReservationFilter() *ReservationFilter

NewReservationFilter returns new instance of ReservationFilter

func (*ReservationFilter) FilterByReservation

func (rf *ReservationFilter) FilterByReservation(reserved bool, acs []accrd.AvailableCapacity,
	acrs []acrcrd.AvailableCapacityReservation) []accrd.AvailableCapacity

FilterByReservation returns AC which are reserved if reserved == true, or not reserved otherwise

type ReservationHelper

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

ReservationHelper provides methods to create and release reservation

func NewReservationHelper

func NewReservationHelper(logger *logrus.Entry, client *k8s.KubeClient,
	capReader CapacityReader) *ReservationHelper

NewReservationHelper returns new instance of ReservationHelper

func (*ReservationHelper) ReleaseReservation

func (rh *ReservationHelper) ReleaseReservation(ctx context.Context, reservation *acrcrd.AvailableCapacityReservation,
	requestNum int) error

ReleaseReservation removes AC from ACR or ACR completely when one volume requested or left

func (*ReservationHelper) UpdateReservation

func (rh *ReservationHelper) UpdateReservation(ctx context.Context, placingPlan *VolumesPlacingPlan,
	nodes []string, reservation *acrcrd.AvailableCapacityReservation) error

UpdateReservation updates reservation CR

type ReservationReader

type ReservationReader interface {
	// ReadReservations read capacity reservations
	ReadReservations(ctx context.Context) ([]acrcrd.AvailableCapacityReservation, error)
}

ReservationReader methods to read capacity reservations

type ReservationReaderMock

type ReservationReaderMock struct {
	mock.Mock
}

ReservationReaderMock is the mock implementation of ReservationReader interface for test purposes

func (*ReservationReaderMock) ReadReservations

ReadReservations is a mock implementation of ReadReservations

type SCToACMap

type SCToACMap map[string]ACMap

SCToACMap SC name to ACMap mapping

type UnreservedACReader

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

UnreservedACReader capReader which returns ACs reserved in ACR

func NewUnreservedACReader

func NewUnreservedACReader(logger *logrus.Entry, capReader CapacityReader,
	resReader ReservationReader) *UnreservedACReader

NewUnreservedACReader returns instance of UnreservedACReader

func (*UnreservedACReader) ReadCapacity

func (rar *UnreservedACReader) ReadCapacity(ctx context.Context) ([]accrd.AvailableCapacity, error)

ReadCapacity returns unreserved ACs

type VolToACListMap

type VolToACListMap map[*genV1.Volume][]*accrd.AvailableCapacity

VolToACListMap volume to AC list mapping

type VolToACMap

type VolToACMap map[*genV1.Volume]*accrd.AvailableCapacity

VolToACMap volume to AC mapping

type VolumesPlacingPlan

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

VolumesPlacingPlan hold information about volumes placing on nodes

func NewVolumesPlacingPlan

func NewVolumesPlacingPlan(volMap VolumesPlanMap, capacityMap NodeCapacityMap) *VolumesPlacingPlan

NewVolumesPlacingPlan returns new instance of VolumesPlacingPlan

func (*VolumesPlacingPlan) GetACForVolume

func (vpp *VolumesPlacingPlan) GetACForVolume(node string, volume *genV1.Volume) *accrd.AvailableCapacity

GetACForVolume returns AC selected for volume on node

func (*VolumesPlacingPlan) GetACsForVolumes

func (vpp *VolumesPlacingPlan) GetACsForVolumes() VolToACListMap

GetACsForVolumes returns mapping between volume and AC list AC list consist of suitable ACs on all nodes

func (*VolumesPlacingPlan) GetVolumesToACMapping

func (vpp *VolumesPlacingPlan) GetVolumesToACMapping(node string) VolToACMap

GetVolumesToACMapping returns volumes to AC mapping for node

func (*VolumesPlacingPlan) SelectNode

func (vpp *VolumesPlacingPlan) SelectNode() string

SelectNode returns less loaded node which has required capacity to create volume

type VolumesPlanMap

type VolumesPlanMap map[string]VolToACMap

VolumesPlanMap NodeID to VolToACMap mapping

Jump to

Keyboard shortcuts

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