volume

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

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

Go to latest
Published: Jan 21, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

README

Volume Drivers

Volume drivers implement the Volume Plugin Interface. This provides an interface to register a volume driver and advertise the driver to Docker. Registering a driver with this volume interface will cause Docker to be able to communicate with the driver to create and assign volumes to a container.

A volume spec is needed to create a volume. A volume spec looks like:

// VolumeSpec has the properties needed to create a volume.
type VolumeSpec struct {
	// Ephemeral storage
	Ephemeral bool
	// Thin provisioned volume size in bytes
	Size uint64
	// Format disk with this FileSystem
	Format Filesystem
	// BlockSize for file system
	BlockSize int
	// HA Level specifies the number of nodes that are
	// allowed to fail, and yet data is availabel.
	// A value of 0 implies that data is not erasure coded,
	// a failure of a node will lead to data loss.
	HALevel int
	// This disk's CoS
	Cos VolumeCos
	// Perform dedupe on this disk
	Dedupe bool
	// SnapshotInterval in minutes, set to 0 to disable Snapshots
	SnapshotInterval int
	// Volume configuration labels
	ConfigLabels Labels
}

Various volume driver implementations can be found in the drivers directory.

Block Drivers

Block drivers operate at the block layer. They provide raw volumes formatted with a user specified filesystem. This volume is then mounted into the container at a path specified using the docker run -v option.

File Drivers

File drivers operate at the filesystem layer.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExist          = errors.New("Driver already exists")
	ErrDriverNotFound = errors.New("Driver implementation not found")
	ErrEnoEnt         = errors.New("Volume does not exist.")
	ErrEnomem         = errors.New("Out of memory.")
	ErrEinval         = errors.New("Invalid argument")
	ErrVolDetached    = errors.New("Volume is detached")
	ErrVolAttached    = errors.New("Volume is attached")
	ErrVolHasSnaps    = errors.New("Volume has snapshots associated")
	ErrNotSupported   = errors.New("Operation not supported")
)

Functions

func Register

func Register(name string, initFunc InitFunc) error

func Shutdown

func Shutdown()

Types

type BlockDriver

type BlockDriver interface {
	// Attach map device to the host.
	// On success the devicePath specifies location where the device is exported
	// Errors ErrEnoEnt, ErrVolAttached may be returned.
	Attach(volumeID api.VolumeID) (string, error)

	// Detach device from the host.
	// Errors ErrEnoEnt, ErrVolDetached may be returned.
	Detach(volumeID api.VolumeID) error
}

BlockDriver needs to be implemented by block volume drivers. Filesystem volume drivers can ignore this interface and include the builtin DefaultBlockDriver.

type DefaultBlockDriver

type DefaultBlockDriver struct {
}

DefaultBlockDriver is a default (null) block driver implementation. This can be used by drivers that do not want to (or care about) implementing the attach, format and detach interfaces.

func (*DefaultBlockDriver) Attach

func (d *DefaultBlockDriver) Attach(volumeID api.VolumeID) (path string, err error)

func (*DefaultBlockDriver) Detach

func (d *DefaultBlockDriver) Detach(volumeID api.VolumeID) error

type DefaultEnumerator

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

DefaultEnumerator for volume information. Implements the Enumerator Interface

func NewDefaultEnumerator

func NewDefaultEnumerator(driver string, kvdb kvdb.Kvdb) *DefaultEnumerator

NewDefaultEnumerator initializes store with specified kvdb.

func (*DefaultEnumerator) CreateVol

func (e *DefaultEnumerator) CreateVol(vol *api.Volume) error

CreateVol returns error if volume with the same ID already existe.

func (*DefaultEnumerator) DeleteVol

func (e *DefaultEnumerator) DeleteVol(volID api.VolumeID) error

DeleteVol. Returns error if volume does not exist.

func (*DefaultEnumerator) Enumerate

func (e *DefaultEnumerator) Enumerate(locator api.VolumeLocator,
	labels api.Labels) ([]api.Volume, error)

Enumerate volumes that map to the volumeLocator. Locator fields may be regexp. If locator fields are left blank, this will return all volumee.

func (*DefaultEnumerator) GetVol

func (e *DefaultEnumerator) GetVol(volID api.VolumeID) (*api.Volume, error)

GetVol from volID.

func (*DefaultEnumerator) Inspect

func (e *DefaultEnumerator) Inspect(ids []api.VolumeID) ([]api.Volume, error)

Inspect specified volumes. Returns slice of volumes that were found.

func (*DefaultEnumerator) Lock

func (e *DefaultEnumerator) Lock(volID api.VolumeID) (interface{}, error)

Lock volume specified by volID.

func (*DefaultEnumerator) SnapEnumerate

func (e *DefaultEnumerator) SnapEnumerate(
	volIDs []api.VolumeID,
	labels api.Labels) ([]api.Volume, error)

SnapEnumerate for specified volume

func (*DefaultEnumerator) Unlock

func (e *DefaultEnumerator) Unlock(token interface{}) error

Lock volume with token obtained from call to Lock.

func (*DefaultEnumerator) UpdateVol

func (e *DefaultEnumerator) UpdateVol(vol *api.Volume) error

UpdateVol with vol

type DriverParams

type DriverParams map[string]string

type Enumerator

type Enumerator interface {
	// Inspect specified volumes.
	// Returns slice of volumes that were found.
	Inspect(volumeIDs []api.VolumeID) ([]api.Volume, error)

	// Enumerate volumes that map to the volumeLocator. Locator fields may be regexp.
	// If locator fields are left blank, this will return all volumes.
	Enumerate(locator api.VolumeLocator, labels api.Labels) ([]api.Volume, error)

	// Enumerate snaps for specified volumes
	SnapEnumerate(volID []api.VolumeID, snapLabels api.Labels) ([]api.Volume, error)
}

Enumerator provides a set of interfaces to get details on a set of volumes.

type IODriver

type IODriver interface {
	// Read sz bytes from specified volume at specified offset.
	// Return number of bytes read and error.
	Read(volumeID api.VolumeID,
		buf []byte,
		sz uint64,
		offset int64) (int64, error)

	// Write sz bytes from specified volume at specified offset.
	// Return number of bytes written and error.
	Write(volumeID api.VolumeID,
		buf []byte,
		sz uint64,
		offset int64) (int64, error)

	// Flush writes to stable storage.
	// Return error.
	Flush(volumeID api.VolumeID) error
}

IODriver interfaces applicable to object store interfaces.

type InitFunc

type InitFunc func(params DriverParams) (VolumeDriver, error)

type IoNotSupported

type IoNotSupported struct {
}

func (*IoNotSupported) Flush

func (io *IoNotSupported) Flush(volumeID api.VolumeID) error

func (*IoNotSupported) Read

func (io *IoNotSupported) Read(volumeID api.VolumeID,
	buf []byte,
	sz uint64,
	offset int64) (int64, error)

func (*IoNotSupported) Write

func (io *IoNotSupported) Write(volumeID api.VolumeID,
	buf []byte,
	sz uint64,
	offset int64) (int64, error)

type ProtoDriver

type ProtoDriver interface {
	// String description of this driver.
	String() string

	// Type of this driver
	Type() api.DriverType

	// Create a new Vol for the specific volume spec.
	// It returns a system generated VolumeID that uniquely identifies the volume
	Create(locator api.VolumeLocator,
		Source *api.Source,
		spec *api.VolumeSpec) (api.VolumeID, error)

	// Delete volume.
	// Errors ErrEnoEnt, ErrVolHasSnaps may be returned.
	Delete(volumeID api.VolumeID) error

	// Mount volume at specified path
	// Errors ErrEnoEnt, ErrVolDetached may be returned.
	Mount(volumeID api.VolumeID, mountpath string) error

	// Unmount volume at specified path
	// Errors ErrEnoEnt, ErrVolDetached may be returned.
	Unmount(volumeID api.VolumeID, mountpath string) error

	// Update not all fields of the spec are supported, ErrNotSupported will be thrown for unsupported
	// updates.
	Set(volumeID api.VolumeID, locator *api.VolumeLocator, spec *api.VolumeSpec) error

	// Snapshot create volume snapshot.
	// Errors ErrEnoEnt may be returned
	Snapshot(volumeID api.VolumeID, readonly bool, locator api.VolumeLocator) (api.VolumeID, error)

	// Stats for specified volume.
	// Errors ErrEnoEnt may be returned
	Stats(volumeID api.VolumeID) (api.Stats, error)

	// Alerts on this volume.
	// Errors ErrEnoEnt may be returned
	Alerts(volumeID api.VolumeID) (api.Alerts, error)

	// Status returns a set of key-value pairs which give low
	// level diagnostic status about this driver.
	Status() [][2]string

	// Shutdown and cleanup.
	Shutdown()
}

ProtoDriver must be implemented by all volume drivers. It specifies the most basic functionality, such as creating and deleting volumes.

type SnapshotNotSupported

type SnapshotNotSupported struct {
}

func (*SnapshotNotSupported) Snapshot

func (s *SnapshotNotSupported) Snapshot(volumeID api.VolumeID, readonly bool, locator api.VolumeLocator) (api.VolumeID, error)

type Store

type Store interface {
	// Lock volume specified by volID.
	Lock(volID api.VolumeID) (interface{}, error)

	// Lock volume with token obtained from call to Lock.
	Unlock(token interface{}) error

	// CreateVol returns error if volume with the same ID already existe.
	CreateVol(vol *api.Volume) error

	// GetVol from volID.
	GetVol(volID api.VolumeID) (*api.Volume, error)

	// UpdateVol with vol
	UpdateVol(vol *api.Volume) error

	// DeleteVol. Returns error if volume does not exist.
	DeleteVol(volID api.VolumeID) error
}

type VolumeDriver

type VolumeDriver interface {
	IODriver
	ProtoDriver
	BlockDriver
	Enumerator
}

VolumeDriver is the main interface to be implemented by any storage driver. Every driver must at minimum implement the ProtoDriver sub interface.

func Get

func Get(name string) (VolumeDriver, error)

func New

func New(name string, params DriverParams) (VolumeDriver, error)

Directories

Path Synopsis
aws
buse
Package buse uses the Linux NBD layer to emulate a block device in user space
Package buse uses the Linux NBD layer to emulate a block device in user space
nfs
pwx
vfs

Jump to

Keyboard shortcuts

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