storageprovisioner

package
v0.0.0-...-0a82276 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: AGPL-3.0 Imports: 29 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(stdcontext.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.

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(ctx stdcontext.Context, scope names.Tag) (watcher.StringsWatcher, error)

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

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

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

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

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

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

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

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

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

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

	// RemoveAttachments removes the specified machine/entity attachments
	// from state.
	RemoveAttachments(stdcontext.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(stdcontext.Context, names.MachineTag) (watcher.NotifyWatcher, error)

	// InstanceIds returns the instance IDs of each machine.
	InstanceIds(stdcontext.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(stdcontext.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(stdcontext.Context, names.MachineTag) (watcher.NotifyWatcher, error)

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

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

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

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

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

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

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

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

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

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

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

	CreateVolumeAttachmentPlans(ctx stdcontext.Context, volumeAttachmentPlans []params.VolumeAttachmentPlan) ([]params.ErrorResult, error)
	RemoveVolumeAttachmentPlan(stdcontext.Context, []params.MachineStorageId) ([]params.ErrorResult, error)
	SetVolumeAttachmentPlanBlockInfo(ctx stdcontext.Context, 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