storageprovisioner

package
v0.0.0-...-6cf1bc9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2016 License: AGPL-3.0 Imports: 22 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.

Types

type Config

type Config struct {
	Scope       names.Tag
	StorageDir  string
	Volumes     VolumeAccessor
	Filesystems FilesystemAccessor
	Life        LifecycleManager
	Registry    storage.ProviderRegistry
	Machines    MachineAccessor
	Status      StatusSetter
	Clock       clock.Clock
}

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() (watcher.StringsWatcher, error)

	// WatchFilesystemAttachments watches for changes to filesystem attachments
	// that this storage provisioner is responsible for.
	WatchFilesystemAttachments() (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)

	// 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 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
}

MachineManifoldConfig defines a storage provisioner's configuration and dependencies.

type ModelManifoldConfig

type ModelManifoldConfig struct {
	APICallerName string
	ClockName     string
	EnvironName   string

	Scope      names.Tag
	StorageDir string
}

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() (watcher.StringsWatcher, error)

	// WatchVolumeAttachments watches for changes to volume attachments
	// that this storage provisioner is responsible for.
	WatchVolumeAttachments() (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)

	// VolumeParams returns the parameters for creating the volumes
	// with the specified tags.
	VolumeParams([]names.VolumeTag) ([]params.VolumeParamsResult, 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)
}

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