core

package
v1.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	NodeAccessReconcilePeriod      = time.Second * 30
	NodeRegistrationCooldownPeriod = time.Second * 30
	AttachISCSIVolumeTimeoutLong   = time.Second * 90
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NodeEventCallback

type NodeEventCallback func(eventType, reason, message string)

type Orchestrator

type Orchestrator interface {
	Bootstrap(monitorTransactions bool) error
	AddFrontend(f frontend.Plugin)
	GetFrontend(ctx context.Context, name string) (frontend.Plugin, error)
	GetVersion(ctx context.Context) (string, error)

	AddBackend(ctx context.Context, configJSON, configRef string) (*storage.BackendExternal, error)
	DeleteBackend(ctx context.Context, backend string) error
	DeleteBackendByBackendUUID(ctx context.Context, backendName, backendUUID string) error
	GetBackend(ctx context.Context, backend string) (*storage.BackendExternal, error)
	GetBackendByBackendUUID(ctx context.Context, backendUUID string) (*storage.BackendExternal, error)
	ListBackends(ctx context.Context) ([]*storage.BackendExternal, error)
	UpdateBackend(
		ctx context.Context, backendName, configJSON, configRef string,
	) (storageBackendExternal *storage.BackendExternal, err error)
	UpdateBackendByBackendUUID(
		ctx context.Context, backendName, configJSON, backendUUID, configRef string,
	) (storageBackendExternal *storage.BackendExternal, err error)
	UpdateBackendState(
		ctx context.Context, backendName, backendState string,
	) (storageBackendExternal *storage.BackendExternal, err error)
	RemoveBackendConfigRef(ctx context.Context, backendUUID, configRef string) (err error)

	AddVolume(ctx context.Context, volumeConfig *storage.VolumeConfig) (*storage.VolumeExternal, error)
	AttachVolume(ctx context.Context, volumeName, mountpoint string, publishInfo *utils.VolumePublishInfo) error
	CloneVolume(ctx context.Context, volumeConfig *storage.VolumeConfig) (*storage.VolumeExternal, error)
	DetachVolume(ctx context.Context, volumeName, mountpoint string) error
	DeleteVolume(ctx context.Context, volume string) error
	GetVolume(ctx context.Context, volumeName string) (*storage.VolumeExternal, error)
	GetVolumeByInternalName(volumeInternal string, ctx context.Context) (volume string, err error)
	GetVolumeExternal(ctx context.Context, volumeName, backendName string) (*storage.VolumeExternal, error)
	LegacyImportVolume(
		ctx context.Context, volumeConfig *storage.VolumeConfig, backendName string, notManaged bool,
		createPVandPVC VolumeCallback,
	) (*storage.VolumeExternal, error)
	ImportVolume(ctx context.Context, volumeConfig *storage.VolumeConfig) (*storage.VolumeExternal, error)
	ListVolumes(ctx context.Context) ([]*storage.VolumeExternal, error)
	PublishVolume(ctx context.Context, volumeName string, publishInfo *utils.VolumePublishInfo) error
	UnpublishVolume(ctx context.Context, volumeName, nodeName string) error
	ResizeVolume(ctx context.Context, volumeName, newSize string) error
	SetVolumeState(ctx context.Context, volumeName string, state storage.VolumeState) error
	ReloadVolumes(ctx context.Context) error

	ListSubordinateVolumes(ctx context.Context, sourceVolumeName string) ([]*storage.VolumeExternal, error)
	GetSubordinateSourceVolume(ctx context.Context, subordinateVolumeName string) (*storage.VolumeExternal, error)

	CreateSnapshot(ctx context.Context, snapshotConfig *storage.SnapshotConfig) (*storage.SnapshotExternal, error)
	GetSnapshot(ctx context.Context, volumeName, snapshotName string) (*storage.SnapshotExternal, error)
	ListSnapshots(ctx context.Context) ([]*storage.SnapshotExternal, error)
	ListSnapshotsByName(ctx context.Context, snapshotName string) ([]*storage.SnapshotExternal, error)
	ListSnapshotsForVolume(ctx context.Context, volumeName string) ([]*storage.SnapshotExternal, error)
	ReadSnapshotsForVolume(ctx context.Context, volumeName string) ([]*storage.SnapshotExternal, error)
	DeleteSnapshot(ctx context.Context, volumeName, snapshotName string) error

	AddStorageClass(ctx context.Context, scConfig *storageclass.Config) (*storageclass.External, error)
	DeleteStorageClass(ctx context.Context, scName string) error
	GetStorageClass(ctx context.Context, scName string) (*storageclass.External, error)
	ListStorageClasses(ctx context.Context) ([]*storageclass.External, error)

	AddNode(ctx context.Context, node *utils.Node, nodeEventCallback NodeEventCallback) error
	GetNode(ctx context.Context, nName string) (*utils.Node, error)
	ListNodes(ctx context.Context) ([]*utils.Node, error)
	DeleteNode(ctx context.Context, nName string) error
	PeriodicallyReconcileNodeAccessOnBackends()

	AddVolumePublication(ctx context.Context, vp *utils.VolumePublication) error
	UpdateVolumePublication(ctx context.Context, nodeName, volumeName string, notSafeToAttach *bool) error
	GetVolumePublication(ctx context.Context, volumeName, nodeName string) (*utils.VolumePublication, error)
	ListVolumePublications(ctx context.Context) ([]*utils.VolumePublicationExternal, error)
	ListVolumePublicationsForVolume(
		ctx context.Context, volumeName string,
	) (publications []*utils.VolumePublicationExternal, err error)
	ListVolumePublicationsForNode(
		ctx context.Context, nodeName string,
	) (publications []*utils.VolumePublicationExternal, err error)
	DeleteVolumePublication(ctx context.Context, volumeName, nodeName string) error

	AddVolumeTransaction(ctx context.Context, volTxn *storage.VolumeTransaction) error
	GetVolumeTransaction(ctx context.Context, volTxn *storage.VolumeTransaction) (*storage.VolumeTransaction, error)
	DeleteVolumeTransaction(ctx context.Context, volTxn *storage.VolumeTransaction) error

	EstablishMirror(
		ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle, replicationPolicy,
		replicationSchedule string,
	) error
	ReestablishMirror(
		ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle, replicationPolicy,
		replicationSchedule string,
	) error
	PromoteMirror(
		ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle, snapshotHandle string,
	) (bool, error)
	GetMirrorStatus(ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle string) (string, error)
	CanBackendMirror(ctx context.Context, backendUUID string) (bool, error)
	ReleaseMirror(ctx context.Context, backendUUID, localVolumeHandle string) error
	GetReplicationDetails(
		ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle string,
	) (string, string, error)

	GetCHAP(ctx context.Context, volumeName, nodeName string) (*utils.IscsiChapInfo, error)
}

type TridentOrchestrator

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

func NewTridentOrchestrator

func NewTridentOrchestrator(client persistentstore.Client) *TridentOrchestrator

NewTridentOrchestrator returns a storage orchestrator instance

func (*TridentOrchestrator) AddBackend

func (o *TridentOrchestrator) AddBackend(
	ctx context.Context, configJSON, configRef string,
) (backendExternal *storage.BackendExternal, err error)

AddBackend handles creation of a new storage backend

func (*TridentOrchestrator) AddFrontend

func (o *TridentOrchestrator) AddFrontend(f frontend.Plugin)

func (*TridentOrchestrator) AddNode

func (o *TridentOrchestrator) AddNode(
	ctx context.Context, node *utils.Node, nodeEventCallback NodeEventCallback,
) (err error)

func (*TridentOrchestrator) AddStorageClass

func (o *TridentOrchestrator) AddStorageClass(
	ctx context.Context, scConfig *storageclass.Config,
) (scExternal *storageclass.External, err error)

func (*TridentOrchestrator) AddVolume

func (o *TridentOrchestrator) AddVolume(
	ctx context.Context, volumeConfig *storage.VolumeConfig,
) (externalVol *storage.VolumeExternal, err error)

func (*TridentOrchestrator) AddVolumePublication

func (o *TridentOrchestrator) AddVolumePublication(
	ctx context.Context, publication *utils.VolumePublication,
) (err error)

AddVolumePublication records the volume publication for a given volume/node pair

func (*TridentOrchestrator) AddVolumeTransaction

func (o *TridentOrchestrator) AddVolumeTransaction(ctx context.Context, volTxn *storage.VolumeTransaction) error

AddVolumeTransaction is called from the volume create, clone, and resize methods to save a record of the operation in case it fails and must be cleaned up later.

func (*TridentOrchestrator) AttachVolume

func (o *TridentOrchestrator) AttachVolume(
	ctx context.Context, volumeName, mountpoint string, publishInfo *utils.VolumePublishInfo,
) (err error)

AttachVolume mounts a volume to the local host. This method is currently only used by Docker, and it should be able to accomplish its task using only the data passed in; it should not need to use the storage controller API. It may be assumed that this method always runs on the host to which the volume will be attached.

func (*TridentOrchestrator) Bootstrap

func (o *TridentOrchestrator) Bootstrap(monitorTransactions bool) error

func (*TridentOrchestrator) CanBackendMirror

func (o *TridentOrchestrator) CanBackendMirror(_ context.Context, backendUUID string) (capable bool, err error)

func (*TridentOrchestrator) CloneVolume

func (o *TridentOrchestrator) CloneVolume(
	ctx context.Context, volumeConfig *storage.VolumeConfig,
) (externalVol *storage.VolumeExternal, err error)

func (*TridentOrchestrator) CreateSnapshot

func (o *TridentOrchestrator) CreateSnapshot(
	ctx context.Context, snapshotConfig *storage.SnapshotConfig,
) (externalSnapshot *storage.SnapshotExternal, err error)

CreateSnapshot creates a snapshot of the given volume

func (*TridentOrchestrator) DeleteBackend

func (o *TridentOrchestrator) DeleteBackend(ctx context.Context, backendName string) (err error)

func (*TridentOrchestrator) DeleteBackendByBackendUUID

func (o *TridentOrchestrator) DeleteBackendByBackendUUID(
	ctx context.Context, backendName, backendUUID string,
) (err error)

func (*TridentOrchestrator) DeleteNode

func (o *TridentOrchestrator) DeleteNode(ctx context.Context, nodeName string) (err error)

func (*TridentOrchestrator) DeleteSnapshot

func (o *TridentOrchestrator) DeleteSnapshot(ctx context.Context, volumeName, snapshotName string) (err error)

DeleteSnapshot deletes a snapshot of the given volume

func (*TridentOrchestrator) DeleteStorageClass

func (o *TridentOrchestrator) DeleteStorageClass(ctx context.Context, scName string) (err error)

func (*TridentOrchestrator) DeleteVolume

func (o *TridentOrchestrator) DeleteVolume(ctx context.Context, volumeName string) (err error)

DeleteVolume does the necessary set up to delete a volume during the course of normal operation, verifying that the volume is present in Trident and creating a transaction to ensure that the delete eventually completes.

func (*TridentOrchestrator) DeleteVolumePublication

func (o *TridentOrchestrator) DeleteVolumePublication(ctx context.Context, volumeName, nodeName string) (err error)

DeleteVolumePublication deletes the record of the volume publication for a given volume/node pair

func (*TridentOrchestrator) DeleteVolumeTransaction

func (o *TridentOrchestrator) DeleteVolumeTransaction(ctx context.Context, volTxn *storage.VolumeTransaction) error

DeleteVolumeTransaction deletes a volume transaction created by addVolumeTransaction.

func (*TridentOrchestrator) DetachVolume

func (o *TridentOrchestrator) DetachVolume(ctx context.Context, volumeName, mountpoint string) (err error)

DetachVolume unmounts a volume from the local host. This method is currently only used by Docker, and it should be able to accomplish its task using only the data passed in; it should not need to use the storage controller API. It may be assumed that this method always runs on the host to which the volume will be attached. It ensures the volume is already mounted, and it attempts to delete the mount point.

func (*TridentOrchestrator) EstablishMirror

func (o *TridentOrchestrator) EstablishMirror(
	ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle, replicationPolicy,
	replicationSchedule string,
) (err error)

EstablishMirror creates a net-new replication mirror relationship between 2 volumes on a backend

func (*TridentOrchestrator) GetBackend

func (o *TridentOrchestrator) GetBackend(
	ctx context.Context, backendName string,
) (backendExternal *storage.BackendExternal, err error)

func (*TridentOrchestrator) GetBackendByBackendUUID

func (o *TridentOrchestrator) GetBackendByBackendUUID(
	ctx context.Context, backendUUID string,
) (backendExternal *storage.BackendExternal, err error)

func (*TridentOrchestrator) GetCHAP

func (o *TridentOrchestrator) GetCHAP(
	ctx context.Context, volumeName, nodeName string,
) (chapInfo *utils.IscsiChapInfo, err error)

func (*TridentOrchestrator) GetFrontend

func (o *TridentOrchestrator) GetFrontend(ctx context.Context, name string) (frontend.Plugin, error)

func (*TridentOrchestrator) GetMirrorStatus

func (o *TridentOrchestrator) GetMirrorStatus(
	ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle string,
) (status string, err error)

GetMirrorStatus returns the current status of the mirror relationship

func (*TridentOrchestrator) GetNode

func (o *TridentOrchestrator) GetNode(ctx context.Context, nName string) (node *utils.Node, err error)

func (*TridentOrchestrator) GetReplicationDetails

func (o *TridentOrchestrator) GetReplicationDetails(
	ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle string,
) (policy, schedule string, err error)

GetReplicationDetails returns the current replication policy and schedule of a relationship

func (*TridentOrchestrator) GetSnapshot

func (o *TridentOrchestrator) GetSnapshot(
	ctx context.Context, volumeName, snapshotName string,
) (snapshotExternal *storage.SnapshotExternal, err error)

func (*TridentOrchestrator) GetStorageClass

func (o *TridentOrchestrator) GetStorageClass(
	ctx context.Context, scName string,
) (scExternal *storageclass.External, err error)

func (*TridentOrchestrator) GetSubordinateSourceVolume

func (o *TridentOrchestrator) GetSubordinateSourceVolume(
	_ context.Context, subordinateVolumeName string,
) (volume *storage.VolumeExternal, err error)

GetSubordinateSourceVolume returns the parent volume for a given subordinate volume.

func (*TridentOrchestrator) GetVersion

func (o *TridentOrchestrator) GetVersion(context.Context) (string, error)

func (*TridentOrchestrator) GetVolume

func (o *TridentOrchestrator) GetVolume(
	ctx context.Context, volumeName string,
) (volExternal *storage.VolumeExternal, err error)

func (*TridentOrchestrator) GetVolumeByInternalName

func (o *TridentOrchestrator) GetVolumeByInternalName(
	volumeInternal string, _ context.Context,
) (volume string, err error)

GetVolumeByInternalName returns a volume by the given internal name

func (*TridentOrchestrator) GetVolumeCreatingTransaction

func (o *TridentOrchestrator) GetVolumeCreatingTransaction(
	ctx context.Context, config *storage.VolumeConfig,
) (*storage.VolumeTransaction, error)

func (*TridentOrchestrator) GetVolumeExternal

func (o *TridentOrchestrator) GetVolumeExternal(
	ctx context.Context, volumeName, backendName string,
) (volExternal *storage.VolumeExternal, err error)

GetVolumeExternal is used by volume import so it doesn't check core's o.volumes to see if the volume exists or not. Instead it asks the driver if the volume exists before requesting the volume size. Returns the VolumeExternal representation of the volume.

func (*TridentOrchestrator) GetVolumePublication

func (o *TridentOrchestrator) GetVolumePublication(
	_ context.Context, volumeName, nodeName string,
) (publication *utils.VolumePublication, err error)

GetVolumePublication returns the volume publication for a given volume/node pair

func (*TridentOrchestrator) GetVolumeTransaction

func (o *TridentOrchestrator) GetVolumeTransaction(
	ctx context.Context, volTxn *storage.VolumeTransaction,
) (*storage.VolumeTransaction, error)

func (*TridentOrchestrator) ImportVolume

func (o *TridentOrchestrator) ImportVolume(
	ctx context.Context, volumeConfig *storage.VolumeConfig,
) (externalVol *storage.VolumeExternal, err error)

func (*TridentOrchestrator) LegacyImportVolume

func (o *TridentOrchestrator) LegacyImportVolume(
	ctx context.Context, volumeConfig *storage.VolumeConfig, backendName string, notManaged bool,
	createPVandPVC VolumeCallback,
) (externalVol *storage.VolumeExternal, err error)

func (*TridentOrchestrator) ListBackends

func (o *TridentOrchestrator) ListBackends(
	ctx context.Context,
) (backendExternals []*storage.BackendExternal, err error)

func (*TridentOrchestrator) ListNodes

func (o *TridentOrchestrator) ListNodes(context.Context) (nodes []*utils.Node, err error)

func (*TridentOrchestrator) ListSnapshots

func (o *TridentOrchestrator) ListSnapshots(context.Context) (snapshots []*storage.SnapshotExternal, err error)

func (*TridentOrchestrator) ListSnapshotsByName

func (o *TridentOrchestrator) ListSnapshotsByName(
	_ context.Context, snapshotName string,
) (snapshots []*storage.SnapshotExternal, err error)

func (*TridentOrchestrator) ListSnapshotsForVolume

func (o *TridentOrchestrator) ListSnapshotsForVolume(
	_ context.Context, volumeName string,
) (snapshots []*storage.SnapshotExternal, err error)

func (*TridentOrchestrator) ListStorageClasses

func (o *TridentOrchestrator) ListStorageClasses(ctx context.Context) (
	scExternals []*storageclass.External, err error,
)

func (*TridentOrchestrator) ListSubordinateVolumes

func (o *TridentOrchestrator) ListSubordinateVolumes(
	_ context.Context, sourceVolumeName string,
) (volumes []*storage.VolumeExternal, err error)

ListSubordinateVolumes returns all subordinate volumes for all source volumes, or all subordinate volumes for a single source volume.

func (*TridentOrchestrator) ListVolumePublications

func (o *TridentOrchestrator) ListVolumePublications(
	context.Context,
) (publications []*utils.VolumePublicationExternal, err error)

ListVolumePublications returns a list of all volume publications

func (*TridentOrchestrator) ListVolumePublicationsForNode

func (o *TridentOrchestrator) ListVolumePublicationsForNode(
	ctx context.Context, nodeName string,
) (publications []*utils.VolumePublicationExternal, err error)

ListVolumePublicationsForNode returns a list of all volume publications for a given node

func (*TridentOrchestrator) ListVolumePublicationsForVolume

func (o *TridentOrchestrator) ListVolumePublicationsForVolume(
	ctx context.Context, volumeName string,
) (publications []*utils.VolumePublicationExternal, err error)

ListVolumePublicationsForVolume returns a list of all volume publications for a given volume

func (*TridentOrchestrator) ListVolumes

func (o *TridentOrchestrator) ListVolumes(context.Context) (volumes []*storage.VolumeExternal, err error)

func (*TridentOrchestrator) PeriodicallyReconcileNodeAccessOnBackends

func (o *TridentOrchestrator) PeriodicallyReconcileNodeAccessOnBackends()

PeriodicallyReconcileNodeAccessOnBackends is intended to be run as a goroutine and will periodically run safeReconcileNodeAccessOnBackend for each backend in the orchestrator

func (*TridentOrchestrator) PromoteMirror

func (o *TridentOrchestrator) PromoteMirror(
	ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle, snapshotHandle string,
) (waitingForSnapshot bool, err error)

PromoteMirror makes the local volume the primary

func (*TridentOrchestrator) PublishVolume

func (o *TridentOrchestrator) PublishVolume(
	ctx context.Context, volumeName string, publishInfo *utils.VolumePublishInfo,
) (err error)

func (*TridentOrchestrator) ReadSnapshotsForVolume

func (o *TridentOrchestrator) ReadSnapshotsForVolume(
	ctx context.Context, volumeName string,
) (externalSnapshots []*storage.SnapshotExternal, err error)

func (*TridentOrchestrator) ReestablishMirror

func (o *TridentOrchestrator) ReestablishMirror(
	ctx context.Context, backendUUID, localVolumeHandle, remoteVolumeHandle, replicationPolicy,
	replicationSchedule string,
) (err error)

ReestablishMirror recreates a previously existing replication mirror relationship between 2 volumes on a backend

func (*TridentOrchestrator) ReleaseMirror

func (o *TridentOrchestrator) ReleaseMirror(
	ctx context.Context, backendUUID, localVolumeHandle string,
) (err error)

ReleaseMirror removes snapmirror relationship infromation and snapshots for a source volume in ONTAP

func (*TridentOrchestrator) ReloadVolumes

func (o *TridentOrchestrator) ReloadVolumes(ctx context.Context) (err error)

func (*TridentOrchestrator) RemoveBackendConfigRef

func (o *TridentOrchestrator) RemoveBackendConfigRef(ctx context.Context, backendUUID, configRef string) (err error)

RemoveBackendConfigRef sets backend configRef to empty and updates it.

func (*TridentOrchestrator) ResizeVolume

func (o *TridentOrchestrator) ResizeVolume(ctx context.Context, volumeName, newSize string) (err error)

ResizeVolume resizes a volume to the new size.

func (*TridentOrchestrator) SetVolumeState

func (o *TridentOrchestrator) SetVolumeState(
	ctx context.Context, volumeName string, state storage.VolumeState,
) (err error)

SetVolumeState sets the state of a volume to a given value

func (*TridentOrchestrator) StartTransactionMonitor

func (o *TridentOrchestrator) StartTransactionMonitor(
	ctx context.Context, txnPeriod, txnMaxAge time.Duration,
)

StartTransactionMonitor starts the thread that reaps abandoned long-running transactions.

func (*TridentOrchestrator) Stop

func (o *TridentOrchestrator) Stop()

Stop stops the orchestrator core.

func (*TridentOrchestrator) StopTransactionMonitor

func (o *TridentOrchestrator) StopTransactionMonitor()

StopTransactionMonitor stops the thread that reaps abandoned long-running transactions.

func (*TridentOrchestrator) UnpublishVolume

func (o *TridentOrchestrator) UnpublishVolume(ctx context.Context, volumeName, nodeName string) (err error)

func (*TridentOrchestrator) UpdateBackend

func (o *TridentOrchestrator) UpdateBackend(
	ctx context.Context, backendName, configJSON, configRef string,
) (backendExternal *storage.BackendExternal, err error)

UpdateBackend updates an existing backend.

func (*TridentOrchestrator) UpdateBackendByBackendUUID

func (o *TridentOrchestrator) UpdateBackendByBackendUUID(
	ctx context.Context, backendName, configJSON, backendUUID, configRef string,
) (backend *storage.BackendExternal, err error)

UpdateBackendByBackendUUID updates an existing backend.

func (*TridentOrchestrator) UpdateBackendState

func (o *TridentOrchestrator) UpdateBackendState(
	ctx context.Context, backendName, backendState string,
) (backendExternal *storage.BackendExternal, err error)

UpdateBackendState updates an existing backend's state.

func (*TridentOrchestrator) UpdateVolumePublication

func (o *TridentOrchestrator) UpdateVolumePublication(
	ctx context.Context, volumeName, nodeName string, notSafeToAttach *bool,
) (err error)

UpdateVolumePublication allows changing the notSafeToAttach flag which will initiate force detach when set from // false to true, and will initiate publication deletion when set from true to false.

type VolumeCallback

type VolumeCallback func(*storage.VolumeExternal, string) error

Jump to

Keyboard shortcuts

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