Documentation ¶
Index ¶
- Constants
- func AlignSizeByPE(size int64) int64
- func FilterACList(acs []accrd.AvailableCapacity, filter func(ac accrd.AvailableCapacity) bool) []accrd.AvailableCapacity
- func FilterACRList(acrs []acrcrd.AvailableCapacityReservation, ...) []acrcrd.AvailableCapacityReservation
- func SubtractLVMMetadataSize(size int64) int64
- type ACMap
- type ACNameToACRNamesMap
- type ACRMap
- type ACRReader
- type ACReader
- type CapacityManager
- type CapacityManagerBuilder
- type CapacityPlaner
- type CapacityReader
- type CapacityReaderMock
- type DefaultCapacityManagerBuilder
- type MockCapacityManagerBuilder
- type NodeCapacityMap
- type PlannerMock
- type ReservationFilter
- type ReservationHelper
- type ReservationReader
- type ReservationReaderMock
- type ReservedCapacityManager
- type SCToACMap
- type UnreservedACReader
- type VolToACListMap
- type VolToACMap
- type VolumesPlacingPlan
- type VolumesPlanMap
Constants ¶
const AcSizeMinThresholdBytes = int64(util.MBYTE) // 1MB
AcSizeMinThresholdBytes means that if AC size becomes lower then AcSizeMinThresholdBytes that AC should be deleted
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
const LvgDefaultMetadataSize = int64(util.MBYTE) // 1MB
LvgDefaultMetadataSize is additional cost for new VG we should consider.
Variables ¶
This section is empty.
Functions ¶
func AlignSizeByPE ¶
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 ¶
func FilterACRList( acrs []acrcrd.AvailableCapacityReservation, filter func(acr acrcrd.AvailableCapacityReservation) bool) []acrcrd.AvailableCapacityReservation
FilterACRList filter for ACR list
func SubtractLVMMetadataSize ¶
SubtractLVMMetadataSize subtracts LVM metadata size from raw drive size
Types ¶
type ACNameToACRNamesMap ¶
ACNameToACRNamesMap AC name to ACR names mapping
type ACRMap ¶
type ACRMap map[string]*acrcrd.AvailableCapacityReservation
ACRMap ACR.Name to ACR mapping
type ACRReader ¶
type ACRReader struct {
// contains filtered or unexported fields
}
ACRReader read ACR from kubernetes API
func NewACRReader ¶
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 ¶
NewACReader returns instance of ACReader
func (*ACReader) ReadCapacity ¶
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) *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) CapacityPlaner // GetReservedCapacityManager returns ReservedCapacityManager GetReservedCapacityManager(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 ¶
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{}
DefaultCapacityManagerBuilder is a builder for default CapacityManagers
func (*DefaultCapacityManagerBuilder) GetCapacityManager ¶
func (dcmb *DefaultCapacityManagerBuilder) GetCapacityManager( logger *logrus.Entry, capReader CapacityReader) CapacityPlaner
GetCapacityManager returns default implementation of CapacityManager
func (*DefaultCapacityManagerBuilder) GetReservedCapacityManager ¶
func (dcmb *DefaultCapacityManagerBuilder) GetReservedCapacityManager( logger *logrus.Entry, capReader CapacityReader, resReader ReservationReader) CapacityPlaner
GetReservedCapacityManager returns default implementation of ReservedCapacityManager
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) 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 ¶
NodeCapacityMap NodeID to ACMap mapping
type PlannerMock ¶
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 ¶
ReservationReaderMock is the mock implementation of ReservationReader interface for test purposes
func (*ReservationReaderMock) ReadReservations ¶
func (rrm *ReservationReaderMock) ReadReservations(ctx context.Context) ([]acrcrd.AvailableCapacityReservation, error)
ReadReservations is a mock implementation of ReadReservations
type ReservedCapacityManager ¶
type ReservedCapacityManager struct {
// contains filtered or unexported fields
}
ReservedCapacityManager provides placing plan when ACR based reservation enabled
func NewReservedCapacityManager ¶
func NewReservedCapacityManager( logger *logrus.Entry, capReader CapacityReader, resReader ReservationReader) *ReservedCapacityManager
NewReservedCapacityManager returns new instance of ReservedCapacityManager
func (*ReservedCapacityManager) PlanVolumesPlacing ¶
func (rcm *ReservedCapacityManager) PlanVolumesPlacing(ctx context.Context, volumes []*genV1.Volume, nodes []string) (*VolumesPlacingPlan, error)
PlanVolumesPlacing build placing plan for reserved volumes
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