diskmanager

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Disk

type Disk struct {
	// AttachNode represent where disk is attached
	AttachNode string `json:"attachNode,omitempty"`

	// Name unique identification for a disk
	Name string `json:"name,omitempty"`

	// DevPath
	DevPath string `json:"devPath,omitempty"`

	// Capacity
	Capacity int64 `json:"capacity,omitempty"`

	// DiskType SSD/HDD/NVME...
	DiskType string `json:"diskType,omitempty"`

	// Status
	Status DiskStatus `json:"status,omitempty"`
}

Disk all disk info about a disk

type DiskManager

type DiskManager interface {
	// GetClusterDisks list all disks by node
	GetClusterDisks() (map[string][]*Disk, error)

	// GetNodeDisks list all disk located on the node
	GetNodeDisks(node string) ([]*Disk, error)

	// ClaimDisk UpdateDiskStatus mark disk to TobeMount/Free/InUse... status
	ClaimDisk(*Disk) error

	// ReleaseDisk update disk to release status
	ReleaseDisk(diskName string) error

	// SelectFreeDisk use a disk and bind it to a volume
	SelectFreeDisk(Disk) (*Disk, error)

	// PreSelectFreeDisks only reserve disks, but not use
	PreSelectFreeDisks([]Disk) (bool, error)
}

DiskManager manage all disks in cluster The operation here needs to ensure thread safety

type DiskStatus

type DiskStatus = string
const (
	DiskStatusInUse     DiskStatus = "InUse"
	DiskStatusFree      DiskStatus = "Free"
	DiskStatusReserved  DiskStatus = "Reserved"
	DiskStatusUnclaimed DiskStatus = "Unclaimed"
	DiskStatusReleased  DiskStatus = "Released"
)

type LocalDiskNodesManager

type LocalDiskNodesManager struct {
	// GetClient for query LocalDiskNode resources from k8s
	GetClient func() (*localdisknode.Kubeclient, error)

	// DiskHandler manage LD resources in cluster
	DiskHandler *localdisk.LocalDiskHandler
	// contains filtered or unexported fields
}

LocalDiskNodesManager manage all disks in the cluster by interacting with LocalDisk resources

func NewLocalDiskManager

func NewLocalDiskManager() *LocalDiskNodesManager

func (*LocalDiskNodesManager) ClaimDisk

func (ldn *LocalDiskNodesManager) ClaimDisk(disk *Disk) error

ClaimDisk claim a LocalDisk by update LocalDisk status to InUse

func (*LocalDiskNodesManager) GetClusterDisks

func (ldn *LocalDiskNodesManager) GetClusterDisks() (map[string][]*Disk, error)

GetClusterDisks Here is just a simple implementation

func (*LocalDiskNodesManager) GetNodeDisks

func (ldn *LocalDiskNodesManager) GetNodeDisks(node string) ([]*Disk, error)

GetNodeDisks get disks which attached on the node

func (*LocalDiskNodesManager) PreSelectFreeDisks

func (ldn *LocalDiskNodesManager) PreSelectFreeDisks(reqDisks []Disk) (bool, error)

func (*LocalDiskNodesManager) ReleaseDisk

func (ldn *LocalDiskNodesManager) ReleaseDisk(diskName string) error

func (*LocalDiskNodesManager) ReserveDisk

func (ldn *LocalDiskNodesManager) ReserveDisk(disk *Disk) error

ReserveDisk reserve a LocalDisk by update LocalDisk status to Reserved

func (*LocalDiskNodesManager) SelectFreeDisk

func (ldn *LocalDiskNodesManager) SelectFreeDisk(reqDisk Disk) (selDisk *Disk, err error)

Jump to

Keyboard shortcuts

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