storage

package
v0.0.0-...-4308112 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResolver

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

NewResolver returns a new storage resolver.

func NewStateOps

func NewStateOps(rw UnitStateReadWriter) *stateOps

NewStateOps returns a new StateOps.

Types

type Attachments

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

Attachments generates storage hooks in response to changes to storage attachments.

func NewAttachments

func NewAttachments(
	ctx context.Context,
	client api.StorageAccessor,
	tag names.UnitTag,
	rw UnitStateReadWriter,
	abort <-chan struct{},
) (*Attachments, error)

NewAttachments returns a new Attachments.

func (*Attachments) CommitHook

func (a *Attachments) CommitHook(ctx context.Context, 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) Pending

func (a *Attachments) Pending() int

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

func (*Attachments) SetDying

func (a *Attachments) SetDying(ctx context.Context) error

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

func (*Attachments) ValidateHook

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

ValidateHook validates the hook against the current State.

type State

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

State describes the State of storage attachments.

func NewState

func NewState() *State

func (*State) Attach

func (s *State) Attach(storageID string)

func (*State) Attached

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

func (*State) Detach

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

func (*State) Empty

func (s *State) Empty() bool

func (*State) ValidateHook

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 StorageResolverOperations

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

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

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

Jump to

Keyboard shortcuts

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