juju: github.com/juju/juju/worker/uniter/storage Index | Files

package storage

import "github.com/juju/juju/worker/uniter/storage"

Package storage contains the storage subsystem for the uniter, responding to changes in storage attachments (lifecycle, volume/filesystem details) by queuing hooks and managing the storage attachments' lifecycle.

Index

Package Files

attachments.go context.go resolver.go state.go

func NewResolver Uses

func NewResolver(logger Logger, storage *Attachments, modelType model.ModelType) resolver.Resolver

NewResolver returns a new storage resolver.

func NewStateOps Uses

func NewStateOps(rw UnitStateReadWriter) *stateOps

NewStateOps returns a new StateOps.

type Attachments Uses

type Attachments struct {
    // contains filtered or unexported fields
}

Attachments generates storage hooks in response to changes to storage attachments, and provides access to information about storage attachments to hooks.

func NewAttachments Uses

func NewAttachments(
    st StorageAccessor,
    tag names.UnitTag,
    rw UnitStateReadWriter,
    abort <-chan struct{},
) (*Attachments, error)

NewAttachments returns a new Attachments.

func (*Attachments) CommitHook Uses

func (a *Attachments) CommitHook(hi hook.Info) error

CommitHook persists the State change encoded in the supplied storage hook, or returns an error if the hook is invalid given current State.

func (*Attachments) Empty Uses

func (a *Attachments) Empty() bool

Empty reports whether or not there are any active storage attachments.

func (*Attachments) Pending Uses

func (a *Attachments) Pending() int

Pending reports the number of storage attachments whose hooks have yet to be run and committed.

func (*Attachments) SetDying Uses

func (a *Attachments) SetDying() error

SetDying ensures that any unprovisioned storage attachments are removed from State.

func (*Attachments) Storage Uses

func (a *Attachments) Storage(tag names.StorageTag) (jujuc.ContextStorageAttachment, error)

Storage returns the ContextStorage with the supplied tag if it was found, and whether it was found.

func (*Attachments) StorageTags Uses

func (a *Attachments) StorageTags() ([]names.StorageTag, error)

StorageTags returns the names.StorageTags for the active storage attachments.

func (*Attachments) ValidateHook Uses

func (a *Attachments) ValidateHook(hi hook.Info) error

ValidateHook validates the hook against the current State.

type Logger Uses

type Logger interface {
    Infof(string, ...interface{})
    Debugf(string, ...interface{})
}

Logger represents the logging methods used in this package.

type State Uses

type State struct {
    // contains filtered or unexported fields
}

State describes the State of storage attachments.

func NewState Uses

func NewState() *State

func (*State) Attach Uses

func (s *State) Attach(storageID string)

func (*State) Attached Uses

func (s *State) Attached(storageID string) (bool, bool)

func (*State) Detach Uses

func (s *State) Detach(storageID string) error

func (*State) Empty Uses

func (s *State) Empty() bool

func (*State) ValidateHook Uses

func (s *State) ValidateHook(hi hook.Info) (err error)

ValidateHook returns an error if the supplied hook.Info does not represent a valid change to the storage State. Hooks must always be validated against the current State before they are run, to ensure that the system meets its guarantees about hook execution order.

type StorageAccessor Uses

type StorageAccessor interface {
    // StorageAttachment returns details of the storage attachment
    // with the specified unit and storage tags.
    StorageAttachment(names.StorageTag, names.UnitTag) (params.StorageAttachment, error)

    // UnitStorageAttachments returns details of all of the storage
    // attachments for the unit with the specified tag.
    UnitStorageAttachments(names.UnitTag) ([]params.StorageAttachmentId, error)

    // DestroyUnitStorageAttachments ensures that all storage
    // attachments for the specified unit will be removed at
    // some point in the future.
    DestroyUnitStorageAttachments(names.UnitTag) error

    // RemoveStorageAttachment removes that the storage attachment
    // with the specified unit and storage tags. This method is only
    // expected to succeed if the storage attachment is Dying.
    RemoveStorageAttachment(names.StorageTag, names.UnitTag) error
}

StorageAccessor is an interface for accessing information about storage attachments.

type StorageResolverOperations Uses

type StorageResolverOperations interface {
    NewUpdateStorage(tags []names.StorageTag) (operation.Operation, error)
    NewRunHook(hookInfo hook.Info) (operation.Operation, error)
}

StorageResolverOperations instances know how to make operations required by the resolver.

type UnitStateReadWriter Uses

type UnitStateReadWriter interface {
    State() (params.UnitStateResult, error)
    SetState(unitState params.SetUnitStateArg) error
}

UnitStateReadWriter encapsulates the methods from a state.Unit required to set and get unit state.

Package storage imports 13 packages (graph) and is imported by 38 packages. Updated 2020-08-13. Refresh now. Tools for package owners.