storageprovisioner

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 27 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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.

func NewCaasWorker

func NewCaasWorker(config Config) (worker.Worker, error)

NewCaasWorker starts and returns a new CAAS storage provisioner worker. The worker provisions model scoped storage and also watches and starts provisioner workers to handle storage for application units.

Types

type ApplicationWatcher

type ApplicationWatcher interface {
	WatchApplications() (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
	CloudCallContextFunc common.CloudCallContextFunc
}

Config holds configuration and dependencies for a storageprovisioner worker.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if the config cannot be relied upon to start a worker.

type FilesystemAccessor

type FilesystemAccessor interface {
	// WatchFilesystems watches for changes to filesystems that this
	// storage provisioner is responsible for.
	WatchFilesystems(scope names.Tag) (watcher.StringsWatcher, error)

	// WatchFilesystemAttachments watches for changes to filesystem attachments
	// that this storage provisioner is responsible for.
	WatchFilesystemAttachments(scope names.Tag) (watcher.MachineStorageIdsWatcher, error)

	// Filesystems returns details of filesystems with the specified tags.
	Filesystems([]names.FilesystemTag) ([]params.FilesystemResult, error)

	// FilesystemAttachments returns details of filesystem attachments with
	// the specified tags.
	FilesystemAttachments([]params.MachineStorageId) ([]params.FilesystemAttachmentResult, error)

	// FilesystemParams returns the parameters for creating the filesystems
	// with the specified tags.
	FilesystemParams([]names.FilesystemTag) ([]params.FilesystemParamsResult, error)

	// RemoveFilesystemParams returns the parameters for destroying or
	// releasing the filesystems with the specified tags.
	RemoveFilesystemParams([]names.FilesystemTag) ([]params.RemoveFilesystemParamsResult, error)

	// FilesystemAttachmentParams returns the parameters for creating the
	// filesystem attachments with the specified tags.
	FilesystemAttachmentParams([]params.MachineStorageId) ([]params.FilesystemAttachmentParamsResult, error)

	// SetFilesystemInfo records the details of newly provisioned filesystems.
	SetFilesystemInfo([]params.Filesystem) ([]params.ErrorResult, error)

	// SetFilesystemAttachmentInfo records the details of newly provisioned
	// filesystem attachments.
	SetFilesystemAttachmentInfo([]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([]names.Tag) ([]params.LifeResult, error)

	// Remove removes the specified entities from state.
	Remove([]names.Tag) ([]params.ErrorResult, error)

	// AttachmentLife returns the lifecycle state of the specified
	// machine/entity attachments.
	AttachmentLife([]params.MachineStorageId) ([]params.LifeResult, error)

	// RemoveAttachments removes the specified machine/entity attachments
	// from state.
	RemoveAttachments([]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 Logger

type Logger interface {
	Tracef(string, ...interface{})
	Debugf(string, ...interface{})
	Warningf(string, ...interface{})
	Errorf(string, ...interface{})
}

Logger represents the methods used by the worker to log details.

type MachineAccessor

type MachineAccessor interface {
	// WatchMachine watches for changes to the specified machine.
	WatchMachine(names.MachineTag) (watcher.NotifyWatcher, error)

	// InstanceIds returns the instance IDs of each machine.
	InstanceIds([]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
	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
}

ModelManifoldConfig defines a storage provisioner's configuration and dependencies.

type StatusSetter

type StatusSetter interface {
	SetStatus([]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(names.MachineTag) (watcher.NotifyWatcher, error)

	// WatchVolumes watches for changes to volumes that this storage
	// provisioner is responsible for.
	WatchVolumes(scope names.Tag) (watcher.StringsWatcher, error)

	// WatchVolumeAttachments watches for changes to volume attachments
	// that this storage provisioner is responsible for.
	WatchVolumeAttachments(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(scope names.Tag) (watcher.MachineStorageIdsWatcher, error)

	// Volumes returns details of volumes with the specified tags.
	Volumes([]names.VolumeTag) ([]params.VolumeResult, error)

	// VolumeBlockDevices returns details of block devices corresponding to
	// the specified volume attachment IDs.
	VolumeBlockDevices([]params.MachineStorageId) ([]params.BlockDeviceResult, error)

	// VolumeAttachments returns details of volume attachments with
	// the specified tags.
	VolumeAttachments([]params.MachineStorageId) ([]params.VolumeAttachmentResult, error)

	VolumeAttachmentPlans([]params.MachineStorageId) ([]params.VolumeAttachmentPlanResult, error)

	// VolumeParams returns the parameters for creating the volumes
	// with the specified tags.
	VolumeParams([]names.VolumeTag) ([]params.VolumeParamsResult, error)

	// RemoveVolumeParams returns the parameters for destroying or
	// releasing the volumes with the specified tags.
	RemoveVolumeParams([]names.VolumeTag) ([]params.RemoveVolumeParamsResult, error)

	// VolumeAttachmentParams returns the parameters for creating the
	// volume attachments with the specified tags.
	VolumeAttachmentParams([]params.MachineStorageId) ([]params.VolumeAttachmentParamsResult, error)

	// SetVolumeInfo records the details of newly provisioned volumes.
	SetVolumeInfo([]params.Volume) ([]params.ErrorResult, error)

	// SetVolumeAttachmentInfo records the details of newly provisioned
	// volume attachments.
	SetVolumeAttachmentInfo([]params.VolumeAttachment) ([]params.ErrorResult, error)

	CreateVolumeAttachmentPlans(volumeAttachmentPlans []params.VolumeAttachmentPlan) ([]params.ErrorResult, error)
	RemoveVolumeAttachmentPlan([]params.MachineStorageId) ([]params.ErrorResult, error)
	SetVolumeAttachmentPlanBlockInfo(volumeAttachmentPlans []params.VolumeAttachmentPlan) ([]params.ErrorResult, error)
}

VolumeAccessor defines an interface used to allow a storage provisioner worker to perform volume related operations.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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