allocdir

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2016 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Functions shared between linux/darwin.

Index

Constants

This section is empty.

Variables

View Source
var (
	// The name of the directory that is shared across tasks in a task group.
	SharedAllocName = "alloc"

	// Name of the directory where logs of Tasks are written
	LogDirName = "logs"

	// The set of directories that exist inside eache shared alloc directory.
	SharedAllocDirs = []string{LogDirName, "tmp", "data"}

	// The name of the directory that exists inside each task directory
	// regardless of driver.
	TaskLocal = "local"

	// TaskSecrets is the name of the secret directory inside each task
	// directory
	TaskSecrets = "secrets"

	// TaskDirs is the set of directories created in each tasks directory.
	TaskDirs = []string{"tmp"}
)
View Source
var (
	// SharedAllocContainerPath is the path inside container for mounted
	// directory shared across tasks in a task group.
	SharedAllocContainerPath = filepath.Join("/", SharedAllocName)

	// TaskLocalContainer is the path inside a container for mounted directory
	// for local storage.
	TaskLocalContainerPath = filepath.Join("/", TaskLocal)

	// TaskSecretsContainerPath is the path inside a container for mounted
	// secrets directory
	TaskSecretsContainerPath = filepath.Join("/", TaskSecrets)
)

Functions

This section is empty.

Types

type AllocDir

type AllocDir struct {
	// AllocDir is the directory used for storing any state
	// of this allocation. It will be purged on alloc destroy.
	AllocDir string

	// The shared directory is available to all tasks within the same task
	// group.
	SharedDir string

	// TaskDirs is a mapping of task names to their non-shared directory.
	TaskDirs map[string]string
}

func NewAllocDir

func NewAllocDir(allocDir string) *AllocDir

NewAllocDir initializes the AllocDir struct with allocDir as base path for the allocation directory.

func (*AllocDir) BlockUntilExists added in v0.4.1

func (d *AllocDir) BlockUntilExists(path string, t *tomb.Tomb) (chan error, error)

BlockUntilExists blocks until the passed file relative the allocation directory exists. The block can be cancelled with the passed tomb.

func (*AllocDir) Build

func (d *AllocDir) Build(tasks []*structs.Task) error

Given a list of a task build the correct alloc structure.

func (*AllocDir) ChangeEvents added in v0.4.1

func (d *AllocDir) ChangeEvents(path string, curOffset int64, t *tomb.Tomb) (*watch.FileChanges, error)

ChangeEvents watches for changes to the passed path relative to the allocation directory. The offset should be the last read offset. The tomb is used to clean up the watch.

func (*AllocDir) Destroy

func (d *AllocDir) Destroy() error

Tears down previously build directory structure.

func (*AllocDir) Embed

func (d *AllocDir) Embed(task string, entries map[string]string) error

Embed takes a mapping of absolute directory or file paths on the host to their intended, relative location within the task directory. Embed attempts hardlink and then defaults to copying. If the path exists on the host and can't be embedded an error is returned.

func (*AllocDir) GetSecretDir added in v0.5.0

func (d *AllocDir) GetSecretDir(task string) (string, error)

func (*AllocDir) List added in v0.3.0

func (d *AllocDir) List(path string) ([]*AllocFileInfo, error)

List returns the list of files at a path relative to the alloc dir

func (*AllocDir) LogDir added in v0.3.0

func (d *AllocDir) LogDir() string

LogDir returns the log dir in the current allocation directory

func (*AllocDir) MountSharedDir

func (d *AllocDir) MountSharedDir(task string) error

MountSharedDir mounts the shared directory into the specified task's directory. Mount is documented at an OS level in their respective implementation files.

func (*AllocDir) MountSpecialDirs added in v0.3.0

func (d *AllocDir) MountSpecialDirs(taskDir string) error

MountSpecialDirs mounts the dev and proc file system from the host to the chroot

func (*AllocDir) Move added in v0.5.0

func (d *AllocDir) Move(other *AllocDir, tasks []*structs.Task) error

Move moves the shared data and task local dirs

func (*AllocDir) ReadAt added in v0.3.0

func (d *AllocDir) ReadAt(path string, offset int64) (io.ReadCloser, error)

ReadAt returns a reader for a file at the path relative to the alloc dir

func (*AllocDir) Snapshot added in v0.5.0

func (d *AllocDir) Snapshot(w io.Writer) error

Snapshot creates an archive of the files and directories in the data dir of the allocation and the task local directories

func (*AllocDir) Stat added in v0.3.0

func (d *AllocDir) Stat(path string) (*AllocFileInfo, error)

Stat returns information about the file at a path relative to the alloc dir

func (*AllocDir) UnmountAll added in v0.3.0

func (d *AllocDir) UnmountAll() error

type AllocDirFS added in v0.3.0

type AllocDirFS interface {
	List(path string) ([]*AllocFileInfo, error)
	Stat(path string) (*AllocFileInfo, error)
	ReadAt(path string, offset int64) (io.ReadCloser, error)
	Snapshot(w io.Writer) error
	BlockUntilExists(path string, t *tomb.Tomb) (chan error, error)
	ChangeEvents(path string, curOffset int64, t *tomb.Tomb) (*watch.FileChanges, error)
}

AllocDirFS exposes file operations on the alloc dir

type AllocFileInfo added in v0.3.0

type AllocFileInfo struct {
	Name     string
	IsDir    bool
	Size     int64
	FileMode string
	ModTime  time.Time
}

AllocFileInfo holds information about a file inside the AllocDir

Jump to

Keyboard shortcuts

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