Documentation
¶
Overview ¶
Package storageprovisioner provides a worker that manages the provisioning and deprovisioning of storage volumes and filesystems, and attaching them to and detaching them from machines.
A storage provisioner worker is run at each model manager, which manages model-scoped storage such as virtual disk services of the cloud provider. In addition to this, each machine agent runs a machine- storage provisioner worker that manages storage scoped to that machine, such as loop devices, temporary filesystems (tmpfs), and rootfs.
The storage provisioner worker is comprised of the following major components:
- a set of watchers for provisioning and attachment events
- a schedule of pending operations
- event-handling code fed by the watcher, that identifies interesting changes (unprovisioned -> provisioned, etc.), ensures prerequisites are met (e.g. volume and machine are both provisioned before attachment is attempted), and populates operations into the schedule
- operation execution code fed by the schedule, that groups operations to make bulk calls to storage providers; updates status; and reschedules operations upon failure
Index ¶
- Variables
- func MachineManifold(config MachineManifoldConfig) dependency.Manifold
- func ModelManifold(config ModelManifoldConfig) dependency.Manifold
- func NewCaasWorker(config Config) (worker.Worker, error)
- type ApplicationWatcher
- type Config
- type FilesystemAccessor
- type LifecycleManager
- type MachineAccessor
- type MachineManifoldConfig
- type ModelManifoldConfig
- type StatusSetter
- type VolumeAccessor
Constants ¶
This section is empty.
Variables ¶
var NewStorageProvisioner = func(config Config) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } w := &storageProvisioner{ config: config, } err := catacomb.Invoke(catacomb.Plan{ Site: &w.catacomb, Work: w.loop, }) if err != nil { return nil, errors.Trace(err) } return w, nil }
NewStorageProvisioner returns a Worker which manages provisioning (deprovisioning), and attachment (detachment) of first-class volumes and filesystems.
Machine-scoped storage workers will be provided with a storage directory, while model-scoped workers will not. If the directory path is non-empty, then it will be passed to the storage source via its config.
Functions ¶
func MachineManifold ¶
func MachineManifold(config MachineManifoldConfig) dependency.Manifold
MachineManifold returns a dependency.Manifold that runs a storage provisioner.
func ModelManifold ¶
func ModelManifold(config ModelManifoldConfig) dependency.Manifold
ModelManifold returns a dependency.Manifold that runs a storage provisioner.
Types ¶
type ApplicationWatcher ¶
type ApplicationWatcher interface {
WatchApplications(context.Context) (watcher.StringsWatcher, error)
}
ApplicationWatcher provides an interface for watching for the lifecycle state changes (including addition) of applications.
type Config ¶
type Config struct {
Model names.ModelTag
Scope names.Tag
StorageDir string
Applications ApplicationWatcher
Volumes VolumeAccessor
Filesystems FilesystemAccessor
Life LifecycleManager
Registry storage.ProviderRegistry
Machines MachineAccessor
Status StatusSetter
Clock clock.Clock
Logger logger.Logger
CloudCallContextFunc common.CloudCallContextFunc
}
Config holds configuration and dependencies for a storageprovisioner worker.
type FilesystemAccessor ¶
type FilesystemAccessor interface {
// WatchFilesystems watches for changes to filesystems that this
// storage provisioner is responsible for.
WatchFilesystems(ctx context.Context, scope names.Tag) (watcher.StringsWatcher, error)
// WatchFilesystemAttachments watches for changes to filesystem attachments
// that this storage provisioner is responsible for.
WatchFilesystemAttachments(ctx context.Context, scope names.Tag) (watcher.MachineStorageIDsWatcher, error)
// Filesystems returns details of filesystems with the specified tags.
Filesystems(context.Context, []names.FilesystemTag) ([]params.FilesystemResult, error)
// FilesystemAttachments returns details of filesystem attachments with
// the specified tags.
FilesystemAttachments(context.Context, []params.MachineStorageId) ([]params.FilesystemAttachmentResult, error)
// FilesystemParams returns the parameters for creating the filesystems
// with the specified tags.
FilesystemParams(context.Context, []names.FilesystemTag) ([]params.FilesystemParamsResult, error)
// RemoveFilesystemParams returns the parameters for destroying or
// releasing the filesystems with the specified tags.
RemoveFilesystemParams(context.Context, []names.FilesystemTag) ([]params.RemoveFilesystemParamsResult, error)
// FilesystemAttachmentParams returns the parameters for creating the
// filesystem attachments with the specified tags.
FilesystemAttachmentParams(context.Context, []params.MachineStorageId) ([]params.FilesystemAttachmentParamsResult, error)
// SetFilesystemInfo records the details of newly provisioned filesystems.
SetFilesystemInfo(context.Context, []params.Filesystem) ([]params.ErrorResult, error)
// SetFilesystemAttachmentInfo records the details of newly provisioned
// filesystem attachments.
SetFilesystemAttachmentInfo(context.Context, []params.FilesystemAttachment) ([]params.ErrorResult, error)
}
FilesystemAccessor defines an interface used to allow a storage provisioner worker to perform filesystem related operations.
type LifecycleManager ¶
type LifecycleManager interface {
// Life returns the lifecycle state of the specified entities.
Life(context.Context, []names.Tag) ([]params.LifeResult, error)
// Remove removes the specified entities from state.
Remove(context.Context, []names.Tag) ([]params.ErrorResult, error)
// AttachmentLife returns the lifecycle state of the specified
// machine/entity attachments.
AttachmentLife(context.Context, []params.MachineStorageId) ([]params.LifeResult, error)
// RemoveAttachments removes the specified machine/entity attachments
// from state.
RemoveAttachments(context.Context, []params.MachineStorageId) ([]params.ErrorResult, error)
}
LifecycleManager defines an interface used to enable a storage provisioner worker to perform lifcycle-related operations on storage entities and attachments.
type MachineAccessor ¶
type MachineAccessor interface {
// WatchMachine watches for changes to the specified machine.
WatchMachine(context.Context, names.MachineTag) (watcher.NotifyWatcher, error)
// InstanceIds returns the instance IDs of each machine.
InstanceIds(context.Context, []names.MachineTag) ([]params.StringResult, error)
}
MachineAccessor defines an interface used to allow a storage provisioner worker to perform machine related operations.
type MachineManifoldConfig ¶
type MachineManifoldConfig struct {
AgentName string
APICallerName string
Clock clock.Clock
Logger logger.Logger
NewCredentialValidatorFacade func(base.APICaller) (common.CredentialAPI, error)
}
MachineManifoldConfig defines a storage provisioner's configuration and dependencies.
type ModelManifoldConfig ¶
type ModelManifoldConfig struct {
APICallerName string
StorageRegistryName string
Clock clock.Clock
Model names.ModelTag
StorageDir string
NewCredentialValidatorFacade func(base.APICaller) (common.CredentialAPI, error)
NewWorker func(config Config) (worker.Worker, error)
Logger logger.Logger
}
ModelManifoldConfig defines a storage provisioner's configuration and dependencies.
type StatusSetter ¶
type StatusSetter interface {
SetStatus(context.Context, []params.EntityStatusArgs) error
}
StatusSetter defines an interface used to set the status of entities.
type VolumeAccessor ¶
type VolumeAccessor interface {
// WatchBlockDevices watches for changes to the block devices of the
// specified machine.
WatchBlockDevices(context.Context, names.MachineTag) (watcher.NotifyWatcher, error)
// WatchVolumes watches for changes to volumes that this storage
// provisioner is responsible for.
WatchVolumes(ctx context.Context, scope names.Tag) (watcher.StringsWatcher, error)
// WatchVolumeAttachments watches for changes to volume attachments
// that this storage provisioner is responsible for.
WatchVolumeAttachments(ctx context.Context, scope names.Tag) (watcher.MachineStorageIDsWatcher, error)
// WatchVolumeAttachmentPlans watches for changes to volume attachments
// destined for this machine. It allows the machine agent to do any extra
// initialization of the attachment, such as logging into the iSCSI target
WatchVolumeAttachmentPlans(ctx context.Context, scope names.Tag) (watcher.MachineStorageIDsWatcher, error)
// Volumes returns details of volumes with the specified tags.
Volumes(context.Context, []names.VolumeTag) ([]params.VolumeResult, error)
// VolumeBlockDevices returns details of block devices corresponding to
// the specified volume attachment IDs.
VolumeBlockDevices(context.Context, []params.MachineStorageId) ([]params.BlockDeviceResult, error)
// VolumeAttachments returns details of volume attachments with
// the specified tags.
VolumeAttachments(context.Context, []params.MachineStorageId) ([]params.VolumeAttachmentResult, error)
VolumeAttachmentPlans(context.Context, []params.MachineStorageId) ([]params.VolumeAttachmentPlanResult, error)
// VolumeParams returns the parameters for creating the volumes
// with the specified tags.
VolumeParams(context.Context, []names.VolumeTag) ([]params.VolumeParamsResult, error)
// RemoveVolumeParams returns the parameters for destroying or
// releasing the volumes with the specified tags.
RemoveVolumeParams(context.Context, []names.VolumeTag) ([]params.RemoveVolumeParamsResult, error)
// VolumeAttachmentParams returns the parameters for creating the
// volume attachments with the specified tags.
VolumeAttachmentParams(context.Context, []params.MachineStorageId) ([]params.VolumeAttachmentParamsResult, error)
// SetVolumeInfo records the details of newly provisioned volumes.
SetVolumeInfo(context.Context, []params.Volume) ([]params.ErrorResult, error)
// SetVolumeAttachmentInfo records the details of newly provisioned
// volume attachments.
SetVolumeAttachmentInfo(context.Context, []params.VolumeAttachment) ([]params.ErrorResult, error)
CreateVolumeAttachmentPlans(ctx context.Context, volumeAttachmentPlans []params.VolumeAttachmentPlan) ([]params.ErrorResult, error)
RemoveVolumeAttachmentPlan(context.Context, []params.MachineStorageId) ([]params.ErrorResult, error)
SetVolumeAttachmentPlanBlockInfo(ctx context.Context, volumeAttachmentPlans []params.VolumeAttachmentPlan) ([]params.ErrorResult, error)
}
VolumeAccessor defines an interface used to allow a storage provisioner worker to perform volume related operations.