volume

package
v3.0.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearInvalidTasksFromListView

func ClearInvalidTasksFromListView(multivCenterCSITopologyEnabled bool)

func ClearTaskInfoObjects

func ClearTaskInfoObjects()

ClearTaskInfoObjects is a go routine which runs in the background to clean up expired taskInfo objects from volumeTaskMap.

func ExtractFaultTypeFromErr

func ExtractFaultTypeFromErr(ctx context.Context, err error) string

ExtractFaultTypeFromErr extracts the fault type from err. Return the vim fault type if the input err is a SoapFault, and can exract the fault type of VimFault. Otherwise, it returns fault type as "csi.fault.Internal".

func ExtractFaultTypeFromVolumeResponseResult

func ExtractFaultTypeFromVolumeResponseResult(ctx context.Context,
	resp *cnstypes.CnsVolumeOperationResult) string

ExtractFaultTypeFromVolumeResponseResult extracts the fault type from CnsVolumeOperationResult. Return the vim fault type is CnsVolumeOperationResult.Fault is set, and can extract the fault type of VimFault. Return "" if CnsVolumeOperationResult.Fault not set.

func IsDiskAttached

func IsDiskAttached(ctx context.Context, vm *cnsvsphere.VirtualMachine, volumeID string,
	checkNVMeController bool) (string, error)

IsDiskAttached checks if the volume is attached to the VM. If the volume is attached to the VM, return disk uuid of the volume, else return empty string.

func IsDiskAttachedToVMs

func IsDiskAttachedToVMs(ctx context.Context, volumeID string, vms []*cnsvsphere.VirtualMachine,
	checkNVMeController bool) (string, error)

IsDiskAttachedToVMs checks if the volume is attached to any of the input VMs. If the volume is attached to the VM, return disk uuid of the volume, else return empty string.

func RemoveTasksMarkedForDeletion

func RemoveTasksMarkedForDeletion(l *ListViewImpl)

RemoveTasksMarkedForDeletion goes over the list of tasks in the map and removes tasks that have been marked for deletion

Types

type CnsSnapshotInfo

type CnsSnapshotInfo struct {
	SnapshotID                string
	SourceVolumeID            string
	SnapshotDescription       string
	SnapshotCreationTimestamp time.Time
}

type CnsVolumeInfo

type CnsVolumeInfo struct {
	DatastoreURL string
	VolumeID     cnstypes.CnsVolumeId
}

CnsVolumeInfo hold information related to volume created by CNS.

type InMemoryMapIf

type InMemoryMapIf interface {
	// Upsert : if task exists in the map, the taskDetails will be overwritten.
	// if the task doesn't exist, the taskDetails will be stored
	Upsert(types.ManagedObjectReference, TaskDetails)
	// Delete task from map
	Delete(types.ManagedObjectReference)
	// Get retrieves a single item from a map
	Get(types.ManagedObjectReference) (TaskDetails, bool)
	// GetAll retrieves all map items
	GetAll() []TaskDetails
	// Count returns the count of all items present in the map
	Count() int
}

InMemoryMapIf is used to not provide direct access to internal mutex or map to methods in the same pkg

func NewTaskMap

func NewTaskMap() InMemoryMapIf

NewTaskMap returns a new instance of TaskMap

type ListViewIf

type ListViewIf interface {
	// AddTask adds task to listView and the internal map
	AddTask(ctx context.Context, taskMoRef types.ManagedObjectReference, ch chan TaskResult) error
	// RemoveTask removes task from listview and the internal map
	RemoveTask(ctx context.Context, taskMoRef types.ManagedObjectReference) error
	// SetVirtualCenter is a setter method for the reference to the global vcenter object.
	// use case: ReloadConfiguration
	SetVirtualCenter(ctx context.Context, virtualCenter *cnsvsphere.VirtualCenter) error
	// MarkTaskForDeletion marks a given task MoRef for deletion by a cleanup goroutine
	// use case: failure to remove task due to a vc issue
	MarkTaskForDeletion(ctx context.Context, taskMoRef types.ManagedObjectReference) error
}

ListViewIf provides methods to start and modify a listView object to monitor CNS tasks. NewListViewImpl satisfies ListViewIf and should be initialized to use the interface methods

type ListViewImpl

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

ListViewImpl is the struct used to manage a single listView instance.

func NewListViewImpl

func NewListViewImpl(ctx context.Context, virtualCenter *cnsvsphere.VirtualCenter,
	client *govmomi.Client) (*ListViewImpl, error)

NewListViewImpl creates a new listView object and starts a goroutine to listen to property collector task updates

func (*ListViewImpl) AddTask

func (l *ListViewImpl) AddTask(ctx context.Context, taskMoRef types.ManagedObjectReference, ch chan TaskResult) error

AddTask adds task to listView and the internal map

func (*ListViewImpl) MarkTaskForDeletion

func (l *ListViewImpl) MarkTaskForDeletion(ctx context.Context, taskMoRef types.ManagedObjectReference) error

MarkTaskForDeletion marks a given task MoRef for deletion by setting a boolean flag in the TaskDetails object

func (*ListViewImpl) RemoveTask

func (l *ListViewImpl) RemoveTask(ctx context.Context, taskMoRef types.ManagedObjectReference) error

RemoveTask removes task from listview and the internal map

func (*ListViewImpl) SetVirtualCenter

func (l *ListViewImpl) SetVirtualCenter(ctx context.Context, virtualCenter *cnsvsphere.VirtualCenter) error

SetVirtualCenter is a setter method for vc. use case: ReloadConfiguration

type Manager

type Manager interface {
	// CreateVolume creates a new volume given its spec.
	// When CreateVolume failed, the second return value (faultType) and third return value(error) need to be set, and
	// should not be nil.
	CreateVolume(ctx context.Context, spec *cnstypes.CnsVolumeCreateSpec) (*CnsVolumeInfo, string, error)
	// AttachVolume attaches a volume to a virtual machine given the spec.
	// When AttachVolume failed, the second return value (faultType) and third return value(error) need to be set, and
	// should not be nil.
	AttachVolume(ctx context.Context, vm *cnsvsphere.VirtualMachine,
		volumeID string, checkNVMeController bool) (string, string, error)
	// DetachVolume detaches a volume from the virtual machine given the spec.
	// When DetachVolume failed, the first return value (faultType) and second return value(error) need to be set, and
	// should not be nil.
	DetachVolume(ctx context.Context, vm *cnsvsphere.VirtualMachine, volumeID string) (string, error)
	// DeleteVolume deletes a volume given its spec.
	// When DeleteVolume failed, the first return value (faultType) and second return value(error) need to be set, and
	// should not be nil.
	DeleteVolume(ctx context.Context, volumeID string, deleteDisk bool) (string, error)
	// UpdateVolumeMetadata updates a volume metadata given its spec.
	UpdateVolumeMetadata(ctx context.Context, spec *cnstypes.CnsVolumeMetadataUpdateSpec) error
	// QueryVolumeInfo calls the CNS QueryVolumeInfo API and return a task, from
	// which CnsQueryVolumeInfoResult is extracted.
	QueryVolumeInfo(ctx context.Context, volumeIDList []cnstypes.CnsVolumeId) (*cnstypes.CnsQueryVolumeInfoResult, error)
	// QueryAllVolume returns all volumes matching the given filter and selection.
	QueryAllVolume(ctx context.Context, queryFilter cnstypes.CnsQueryFilter,
		querySelection cnstypes.CnsQuerySelection) (*cnstypes.CnsQueryResult, error)
	// QueryVolumeAsync returns CnsQueryResult matching the given filter by using
	// CnsQueryAsync API. QueryVolumeAsync takes querySelection spec, which helps
	// to specify which fields have to be returned for the query entities. All
	// volume fields would be returned as part of the CnsQueryResult, if the
	// querySelection parameters are not specified.
	QueryVolumeAsync(ctx context.Context, queryFilter cnstypes.CnsQueryFilter,
		querySelection *cnstypes.CnsQuerySelection) (*cnstypes.CnsQueryResult, error)
	// QueryVolume returns volumes matching the given filter.
	QueryVolume(ctx context.Context, queryFilter cnstypes.CnsQueryFilter) (*cnstypes.CnsQueryResult, error)
	// RelocateVolume migrates volumes to their target datastore as specified in relocateSpecList.
	RelocateVolume(ctx context.Context, relocateSpecList ...cnstypes.BaseCnsVolumeRelocateSpec) (*object.Task, error)
	// ExpandVolume expands a volume to a new size.
	// When ExpandVolume failed, the first return value (faultType) and second return value(error) need to be set, and
	// should not be nil.
	ExpandVolume(ctx context.Context, volumeID string, size int64) (string, error)
	// ResetManager helps set new manager instance and VC configuration.
	ResetManager(ctx context.Context, vcenter *cnsvsphere.VirtualCenter) error
	// ConfigureVolumeACLs configures net permissions for a given CnsVolumeACLConfigureSpec.
	ConfigureVolumeACLs(ctx context.Context, spec cnstypes.CnsVolumeACLConfigureSpec) error
	// RegisterDisk registers virtual disks as FCDs using Vslm endpoint.
	RegisterDisk(ctx context.Context, path string, name string) (string, error)
	// RetrieveVStorageObject helps in retreiving virtual disk information for a given volume id.
	RetrieveVStorageObject(ctx context.Context, volumeID string) (*vim25types.VStorageObject, error)
	// ProtectVolumeFromVMDeletion sets keepAfterDeleteVm control flag on migrated volume
	ProtectVolumeFromVMDeletion(ctx context.Context, volumeID string) error
	// CreateSnapshot helps create a snapshot for a block volume
	CreateSnapshot(ctx context.Context, volumeID string, desc string) (*CnsSnapshotInfo, error)
	// DeleteSnapshot helps delete a snapshot for a block volume
	DeleteSnapshot(ctx context.Context, volumeID string, snapshotID string) error
	// QuerySnapshots retrieves the list of snapshots based on the query filter.
	QuerySnapshots(ctx context.Context, snapshotQueryFilter cnstypes.CnsSnapshotQueryFilter) (
		*cnstypes.CnsSnapshotQueryResult, error)
	// MonitorCreateVolumeTask monitors the CNS task which is created for volume creation
	// as part of volume idempotency feature
	MonitorCreateVolumeTask(ctx context.Context,
		volumeOperationDetails **cnsvolumeoperationrequest.VolumeOperationRequestDetails,
		task *object.Task, volNameFromInputSpec string, clusterID string) (*CnsVolumeInfo, string, error)
	// GetOperationStore returns the VolumeOperationRequest interface
	GetOperationStore() cnsvolumeoperationrequest.VolumeOperationRequest
}

Manager provides functionality to manage volumes.

func GetManager

func GetManager(ctx context.Context, vc *cnsvsphere.VirtualCenter,
	operationStore cnsvolumeoperationrequest.VolumeOperationRequest,
	idempotencyHandlingEnabled bool, multivCenterEnabled bool,
	multivCenterTopologyDeployment bool, tasksListViewEnabled bool) (Manager, error)

GetManager returns the Manager instance.

type TaskDetails

type TaskDetails struct {
	Reference types.ManagedObjectReference
	// MarkedForRemoval helps in retrying the removal of tasks in case of failures
	MarkedForRemoval bool
	// channel to return results. the caller (CSI op) is waiting on this channel
	ResultCh chan TaskResult
}

TaskDetails is used to hold state for a task

type TaskMap

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

TaskMap binds together the task details map and a mutex to guard it

func (*TaskMap) Count

func (t *TaskMap) Count() int

Count returns the number of tasks present in the map

func (*TaskMap) Delete

func (t *TaskMap) Delete(task types.ManagedObjectReference)

Delete deletes items from the map and requires an exclusive write lock

func (*TaskMap) Get

Get retrieves a single item from the map and requires a read lock

func (*TaskMap) GetAll

func (t *TaskMap) GetAll() []TaskDetails

GetAll retrieves all tasks from the map and requires a read lock

func (*TaskMap) Upsert

func (t *TaskMap) Upsert(task types.ManagedObjectReference, taskDetails TaskDetails)

Upsert adds/updates items and requires an exclusive write lock

type TaskResult

type TaskResult struct {
	TaskInfo *types.TaskInfo
	Err      error
}

Jump to

Keyboard shortcuts

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