dfs

package
v0.0.0-...-1c5d739 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 26 Imported by: 7

Documentation

Index

Constants

View Source
const (
	BackupMetadataFile   = ".BACKUPINFO"
	SnapshotsMetadataDir = "SNAPSHOTS/"
	DockerImagesFile     = "IMAGES.dkr"
)
View Source
const (
	ServicesMetadataFile = "./.snapshot/services.json"
	ImagesMetadataFile   = "./.snapshot/images.json"
)

Variables

View Source
var (
	ErrRunningContainer = errors.New("container is running")
	ErrStaleContainer   = errors.New("container is stale")
)
View Source
var (
	ErrRestoreNoInfo        = errors.New("backup is missing metadata")
	ErrInvalidBackupVersion = errors.New("backup has an invalid version")
)
View Source
var (
	ErrDFSStatusUnavailable = errors.New("Unable to get storage status for dfs root")
)
View Source
var (
	ErrImageCollision = errors.New("registry image collision")
)

Functions

This section is empty.

Types

type BackupInfo

type BackupInfo struct {
	Templates        []servicetemplate.ServiceTemplate
	BaseImages       []string
	Pools            []pool.ResourcePool
	Snapshots        []string
	SnapshotExcludes map[string][]string
	Timestamp        time.Time
	BackupVersion    int
}

BackupInfo provides meta info about a backup

func ExtractBackupInfo

func ExtractBackupInfo(filename string) (*BackupInfo, error)

ExtractBackupInfo extracts the backup metadata from a tarball on disk in as cheaply a manner as possible. The serialized BackupInfo is stored at the front of the tarball to facilitate this.

type Clock

type Clock interface {
	Now() time.Time
	Since(t time.Time) time.Duration
}

type DFS

type DFS interface {
	DFSLocker
	// Timeout returns the dfs timeout setting
	Timeout() time.Duration
	// Create sets up a new application
	Create(tenantID string) error
	// Destroy removes an existing application
	Destroy(tenantID string) error
	// Download adds an image for an application into the registry
	Download(image, tenantID string, upgrade bool) (registry string, err error)
	// Commit uploads a new image into the registry
	Commit(ctrID string) (tenantID string, err error)
	// Snapshot captures application data at a specific point in time
	Snapshot(info SnapshotInfo, SnapshotSpacePercent int) (string, error)
	// Rollback reverts application to a specific snapshot
	Rollback(snapshotID string) error
	// Delete deletes an application's snapshot
	Delete(snapshotID string) error
	// List lists snapshots for a particular application
	List(tenantID string) (snapshots []string, err error)
	// Info provides detailed info for a particular snapshot
	Info(snapshotID string) (*SnapshotInfo, error)
	// Backup saves and exports the current state of the system
	Backup(info BackupInfo, w io.Writer) error
	// Restore restores the system to the state of the backup
	Restore(r io.Reader, version int) error
	// BackupInfo provides detailed info for a particular backup
	BackupInfo(r io.Reader) (*BackupInfo, error)
	// Tag adds a tag to an existing snapshot
	Tag(snapshotID string, tagName string) error
	// Untag removes a tag from an existing snapshot
	Untag(tenantID, tagName string) (string, error)
	// TagInfo provides detailed info for a particular snapshot by given tag
	TagInfo(tenantID, tagName string) (*SnapshotInfo, error)
	// UpgradeRegistry loads images for each service
	// into the docker registry index
	UpgradeRegistry(svcs []service.ServiceDetails, tenantID, registryHost string, override bool) error
	// Override replaces an image in the registry with a new image
	Override(newImage, oldImage string) error
	// Get docker image information
	GetImageInfo(image string) (*ImageInfo, error)
	// Get estimated size of docker image pull for backup
	EstimateImagePullSize(images []string) (uint64, error)
	// Get free disk space for a path
	DfPath(path string, excludes []string) (uint64, error)
	// Verifies that the mount points are correct. Returns nil if there are no problems.
	VerifyTenantMounts(tenantID string) (err error)
}

DFS is the api for the distributed filesystem

type DFSLocker

type DFSLocker interface {
	// Lock blocks until it can acquire the lock.
	// opName is the name of the operation you are about to perform.
	Lock(opName string)
	// LockWithTimeout blocks up to the timeout specified, then returns.
	// opName is the name of the operation you are about to perform.
	LockWithTimeout(opName string, timeout time.Duration) error
	// Unlock releases the lock.
	// It is a run-time error (panic) if the mutex is not locked.
	Unlock()
}

type DefaultClock

type DefaultClock struct{}

func (*DefaultClock) Now

func (c *DefaultClock) Now() time.Time

func (*DefaultClock) Since

func (c *DefaultClock) Since(t time.Time) time.Duration

type DistributedFilesystem

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

DistributedFilesystem manages disk and registry data for all system applications.

func NewDistributedFilesystem

func NewDistributedFilesystem(docker docker.Docker, index registry.RegistryIndex, reg registry.Registry, disk volume.Driver, net storage.StorageDriver, timeout time.Duration) *DistributedFilesystem

NewDistributedFilesystem instantiates a new DistributedFilsystem object

func (*DistributedFilesystem) Backup

func (dfs *DistributedFilesystem) Backup(data BackupInfo, w io.Writer) error

Backup writes all application data into an export stream

func (*DistributedFilesystem) BackupInfo

func (dfs *DistributedFilesystem) BackupInfo(r io.Reader) (*BackupInfo, error)

BackupInfo provides metadata info about the contents of a backup

func (*DistributedFilesystem) Commit

func (dfs *DistributedFilesystem) Commit(ctrID string) (string, error)

Commit commits a container spawned from the latest docker registry image and updates the registry. Returns the affected registry image.

func (*DistributedFilesystem) Create

func (dfs *DistributedFilesystem) Create(tenantID string) error

Create initializes an application volume on the dfs

func (*DistributedFilesystem) Delete

func (dfs *DistributedFilesystem) Delete(snapshotID string) error

Delete removes application data of a particular snapshot from the dfs and registry.

func (*DistributedFilesystem) Destroy

func (dfs *DistributedFilesystem) Destroy(tenantID string) error

Destroy destroys all application data from the dfs and docker registry

func (*DistributedFilesystem) DfPath

func (dfs *DistributedFilesystem) DfPath(path string, excludes []string) (uint64, error)

func (*DistributedFilesystem) Download

func (dfs *DistributedFilesystem) Download(image, tenantID string, upgrade bool) (string, error)

Download will download the image from upstream and save the image to the registry.

func (*DistributedFilesystem) EstimateImagePullSize

func (dfs *DistributedFilesystem) EstimateImagePullSize(images []string) (uint64, error)

func (*DistributedFilesystem) GetImageInfo

func (dfs *DistributedFilesystem) GetImageInfo(image string) (*ImageInfo, error)

func (*DistributedFilesystem) Info

func (dfs *DistributedFilesystem) Info(snapshotID string) (*SnapshotInfo, error)

Info returns information about an existing snapshot.

func (*DistributedFilesystem) List

func (dfs *DistributedFilesystem) List(tenantID string) ([]string, error)

List returns the list of snapshots for a given tenant.

func (*DistributedFilesystem) Lock

func (dfs *DistributedFilesystem) Lock(opName string)

func (*DistributedFilesystem) LockWithTimeout

func (dfs *DistributedFilesystem) LockWithTimeout(opName string, timeout time.Duration) error

func (*DistributedFilesystem) Override

func (dfs *DistributedFilesystem) Override(newimg, oldimg string) error

Override replaces an image in the docker registry with a new image and updates the registry.

func (*DistributedFilesystem) Restore

func (dfs *DistributedFilesystem) Restore(r io.Reader, version int) error

Restore restores application data from a backup.

func (*DistributedFilesystem) Rollback

func (dfs *DistributedFilesystem) Rollback(snapshotID string) error

Rollback reverts an application to a previous snapshot.

func (*DistributedFilesystem) SetTmp

func (dfs *DistributedFilesystem) SetTmp(tmp string)

SetTmp sets the temp directory for the spooler

func (*DistributedFilesystem) Snapshot

func (dfs *DistributedFilesystem) Snapshot(data SnapshotInfo, spaceFactor int) (string, error)

Snapshot saves the current state of a particular application

func (*DistributedFilesystem) Tag

func (dfs *DistributedFilesystem) Tag(snapshotID string, tagName string) error

Tag adds tags to an existing snapshot

func (*DistributedFilesystem) TagInfo

func (dfs *DistributedFilesystem) TagInfo(tenantID, tagName string) (*SnapshotInfo, error)

TagInfo returns information about an existing snapshot referenced by tag.

func (*DistributedFilesystem) Timeout

func (dfs *DistributedFilesystem) Timeout() time.Duration

Timeout returns the service timeout time for the distributed filesystem

func (*DistributedFilesystem) Unlock

func (dfs *DistributedFilesystem) Unlock()

func (*DistributedFilesystem) Untag

func (dfs *DistributedFilesystem) Untag(tenantID, tagName string) (string, error)

Untag removes an existing snapshot tag and returns the name of the affected snapshot.

func (*DistributedFilesystem) UpgradeRegistry

func (dfs *DistributedFilesystem) UpgradeRegistry(svcs []service.ServiceDetails, tenantID, registryHost string, override bool) error

UpgradeRegistry loads images for each service into the docker registry index. Also migrates images from a previous (or V1) registry at registryHost (host:port).

func (*DistributedFilesystem) VerifyTenantMounts

func (dfs *DistributedFilesystem) VerifyTenantMounts(tenantID string) error

Verifies that the mount points are correct. Returns nil if there are no problems; returns an error if we had problems getting the backing devices or if the devices don't match.

type ErrDfsBusy

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

func (ErrDfsBusy) Error

func (e ErrDfsBusy) Error() string

type ErrTenantMountsInvalid

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

func (ErrTenantMountsInvalid) Error

func (err ErrTenantMountsInvalid) Error() string

type ImageInfo

type ImageInfo struct {
	Size        int64
	VirtualSize int64
}

ImageInfo provides meta info about a Docker image

type ProgressCounter

type ProgressCounter struct {
	Total uint64
	Log   func()
	// contains filtered or unexported fields
}

func NewProgressCounter

func NewProgressCounter(interval int) *ProgressCounter

func NewProgressCounterWithClock

func NewProgressCounterWithClock(interval int, clock Clock) *ProgressCounter

func (*ProgressCounter) Write

func (pc *ProgressCounter) Write(data []byte) (int, error)

type SnapshotInfo

type SnapshotInfo struct {
	*volume.SnapshotInfo
	Images   []string
	Services []service.Service
}

SnapshotInfo provides meta info about a snapshot

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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