juju: github.com/juju/juju/worker/storageprovisioner Index | Files | Directories

package storageprovisioner

import "github.com/juju/juju/worker/storageprovisioner"

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

Package Files

blockdevices.go caasworker.go common.go config.go filesystem_events.go filesystem_ops.go machines.go manifold_machine.go manifold_model.go noopfs.go schedule.go storageprovisioner.go volume_events.go volume_ops.go

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.

func MachineManifold Uses

func MachineManifold(config MachineManifoldConfig) dependency.Manifold

MachineManifold returns a dependency.Manifold that runs a storage provisioner.

func ModelManifold Uses

func ModelManifold(config ModelManifoldConfig) dependency.Manifold

ModelManifold returns a dependency.Manifold that runs a storage provisioner.

func NewCaasWorker Uses

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.

type ApplicationWatcher Uses

type ApplicationWatcher interface {
    WatchApplications() (watcher.StringsWatcher, error)
}

ApplicationWatcher provides an interface for watching for the lifecycle state changes (including addition) of applications.

type Config Uses

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
    CloudCallContext environscontext.ProviderCallContext
}

Config holds configuration and dependencies for a storageprovisioner worker.

func (Config) Validate Uses

func (config Config) Validate() error

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

type FilesystemAccessor Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

type StatusSetter interface {
    SetStatus([]params.EntityStatusArgs) error
}

StatusSetter defines an interface used to set the status of entities.

type VolumeAccessor Uses

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

PathSynopsis
internal/schedule

Package storageprovisioner imports 23 packages (graph) and is imported by 56 packages. Updated 2019-10-19. Refresh now. Tools for package owners.