provisioner

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeLonghornV1 = "LonghornV1"
	TypeLonghornV2 = "LonghornV2"
	TypeLVM        = "LVM"

	// longhorn disk tags
	ErrorCacheDiskTagsNotInitialized = "CacheDiskTags is not initialized"

	// longhorn MountStatus
	NeedMountUpdateNoOp NeedMountUpdateOP = 1 << iota
	NeedMountUpdateMount
	NeedMountUpdateUnmount
)

Variables

This section is empty.

Functions

func ResolvePersistentDevPath

func ResolvePersistentDevPath(device *diskv1.BlockDevice) (string, error)

ResolvePersistentDevPath tries to determine the currently active short device path (e.g. "/dev/sda") for a given block device. When the scanner first finds a new block device, device.Spec.DevPath is set to the short device path at that time, and device.Status.DeviceStatus.Details is filled in with data that uniquely identifies the device (e.g.: WWN). It's possible that on subsequent reboots, the short path will change, for example if devices are added or removed, so we have this function to try to figure out the _current_ short device path based on the unique identifying information in device.Status.DeviceStatus.Details.

func SetCondDeviceFormattingFail

func SetCondDeviceFormattingFail(device *diskv1.BlockDevice, err error)

Types

type DiskTags

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

DiskTags is a cache mechanism for the blockdevices Tags (spec.Tags), it only changed from Harvester side.

func NewLonghornDiskTags

func NewLonghornDiskTags() *DiskTags

func (*DiskTags) DeleteDiskTags

func (d *DiskTags) DeleteDiskTags(dev string)

func (*DiskTags) DevExist

func (d *DiskTags) DevExist(dev string) bool

func (*DiskTags) GetDiskTags

func (d *DiskTags) GetDiskTags(dev string) []string

func (*DiskTags) Initialized

func (d *DiskTags) Initialized() bool

func (*DiskTags) UpdateDiskTags

func (d *DiskTags) UpdateDiskTags(dev string, tags []string)

func (*DiskTags) UpdateInitialized

func (d *DiskTags) UpdateInitialized()

type LVMProvisioner added in v0.7.2

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

func (*LVMProvisioner) Format added in v0.7.2

func (l *LVMProvisioner) Format(devPath string) (isFormatComplete, isRequeueNeeded bool, err error)

Format operation on the LVM use to ensure the device is clean and ready to be used by LVM.

func (*LVMProvisioner) GetProvisionerName added in v0.7.2

func (l *LVMProvisioner) GetProvisionerName() string

func (*LVMProvisioner) Provision added in v0.7.2

func (l *LVMProvisioner) Provision() (bool, error)

Provision creates (if needed) a LVMVolumeGroup CRD and update the corresponding fields.

func (*LVMProvisioner) UnFormat added in v0.7.2

func (l *LVMProvisioner) UnFormat() (bool, error)

func (*LVMProvisioner) UnProvision added in v0.7.2

func (l *LVMProvisioner) UnProvision() (bool, error)

UnProvision update the LVMVolumeGroup CRD and remove the LVMVolumeGroup CRD if the device is the last one in the VG.

func (*LVMProvisioner) Update added in v0.7.2

func (l *LVMProvisioner) Update() (requeue bool, err error)

type LonghornV1Provisioner

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

func (*LonghornV1Provisioner) Format

func (p *LonghornV1Provisioner) Format(devPath string) (bool, bool, error)

func (*LonghornV1Provisioner) GetProvisionerName

func (p *LonghornV1Provisioner) GetProvisionerName() string

func (*LonghornV1Provisioner) Provision

func (p *LonghornV1Provisioner) Provision() (bool, error)

func (*LonghornV1Provisioner) UnFormat

func (p *LonghornV1Provisioner) UnFormat() (bool, error)

func (*LonghornV1Provisioner) UnProvision

func (p *LonghornV1Provisioner) UnProvision() (bool, error)

func (*LonghornV1Provisioner) Update

func (p *LonghornV1Provisioner) Update() (bool, error)

Update is used to update the disk tags

type LonghornV2Provisioner added in v0.7.2

type LonghornV2Provisioner struct {
	*LonghornV1Provisioner
}

func (*LonghornV2Provisioner) Format added in v0.7.2

func (p *LonghornV2Provisioner) Format(devPath string) (isFormatComplete, isRequeueNeeded bool, err error)

Format should really be a no-op for V2 disks given they just take the whole device, but for NVMe devices where Longhorn decides to use the nvme bdev driver, device activation will fail if there's an existing filesystem on the device, so we need to make sure to wipe before use.

func (*LonghornV2Provisioner) Provision added in v0.7.2

func (p *LonghornV2Provisioner) Provision() (isRequeueNeeded bool, err error)

Provision adds the block device to longhorn's list of disks. Longhorn's admission webhook will deny the update if the V2 engine isn't enabled (you'll see something like 'admission webhook "validator.longhorn.io" denied the request: update disk on node harvester-node-0 error: The disk 989754e4e66edadfd3390974a1aba3f8(/dev/sda) is a block device, but the SPDK feature is not enabled')

func (*LonghornV2Provisioner) UnFormat added in v0.7.2

func (p *LonghornV2Provisioner) UnFormat() (isRequeueNeeded bool, err error)

UnFormat is a no-op for V2 disks

func (*LonghornV2Provisioner) UnProvision added in v0.7.2

func (p *LonghornV2Provisioner) UnProvision() (isRequeueNeeded bool, err error)

func (*LonghornV2Provisioner) Update added in v0.7.2

func (p *LonghornV2Provisioner) Update() (isRequeueNeeded bool, err error)

type NeedMountUpdateOP

type NeedMountUpdateOP int8

func (NeedMountUpdateOP) Has

type Provisioner

type Provisioner interface {
	// Format is the Prerequisites for the provisioner
	// You should do the format-related operations (including mkfs, mount ...etc) here
	// Return values: bool1: isFormatComplete, bool2: isRequeueNeeded, error: error
	Format(string) (bool, bool, error)

	// UnFormat is the cleanup operation for the provisioner
	// You should call this after the UnProvision (if needed)
	// Return values: bool: isRequeueNeeded, error: error
	UnFormat() (bool, error)

	// Provision is the main operation for the provisioner
	// You should do all provision things like provision to specific storage, add to volume group ...etc
	// Return values: bool: isRequeueNeeded, error: error
	Provision() (bool, error)

	// UnProvision is the cleanup operation for the provisioner
	// You should cleanup all the things like remove from volume group, unprovision from storage ...etc
	// Return values: bool: isRequeueNeeded, error: error
	UnProvision() (bool, error)

	// Update is the mechanism to update anything you needed.
	// Like tags on the longhorn nodes, ensure the vg active for LVM ...etc
	// Return values: bool: isRequeueNeeded, error: error
	Update() (bool, error)
}

func NewLHV1Provisioner

func NewLHV1Provisioner(
	device *diskv1.BlockDevice,
	block block.Info,
	nodeObj *longhornv1.Node,
	nodesClient ctllonghornv1.NodeClient,
	nodesClientCache ctllonghornv1.NodeCache,
	cacheDiskTags *DiskTags,
	semaphore *Semaphore,
) (Provisioner, error)

func NewLHV2Provisioner added in v0.7.2

func NewLHV2Provisioner(
	device *diskv1.BlockDevice,
	block block.Info,
	nodeObj *longhornv1.Node,
	nodesClient ctllonghornv1.NodeClient,
	nodesClientCache ctllonghornv1.NodeCache,
	cacheDiskTags *DiskTags,
) (Provisioner, error)

func NewLVMProvisioner added in v0.7.2

func NewLVMProvisioner(vgName, nodeName string, lvmVGs ctldiskv1.LVMVolumeGroupController, device *diskv1.BlockDevice, blockInfo block.Info, lock *sync.Mutex) (Provisioner, error)

type Semaphore

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

semaphore is a simple semaphore implementation in channel

func NewSemaphore

func NewSemaphore(n uint) *Semaphore

newSemaphore creates a new semaphore with the given capacity.

Jump to

Keyboard shortcuts

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