allocdir

package
v0.5.6-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2017 License: MPL-2.0 Imports: 16 Imported by: 422

Documentation

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"

	// SharedDataDir is one of the shared allocation directories. It is
	// included in snapshots.
	SharedDataDir = "data"

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

	// 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]*TaskDir
	// contains filtered or unexported fields
}

func NewAllocDir

func NewAllocDir(logger *log.Logger, 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() error

Build the directory tree for an allocation.

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) 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) Move added in v0.5.0

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

Move other alloc directory's shared path and local dir to this alloc dir.

func (*AllocDir) NewTaskDir added in v0.5.3

func (d *AllocDir) NewTaskDir(name string) *TaskDir

NewTaskDir creates a new TaskDir and adds it to the AllocDirs TaskDirs map.

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

UnmountAll linked/mounted directories in task dirs.

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

type TaskDir added in v0.5.3

type TaskDir struct {
	// Dir is the path to Task directory on the host
	Dir string

	// SharedAllocDir is the path to shared alloc directory on the host
	// <alloc_dir>/alloc/
	SharedAllocDir string

	// SharedTaskDir is the path to the shared alloc directory linked into
	// the task directory on the host.
	// <task_dir>/alloc/
	SharedTaskDir string

	// LocalDir is the path to the task's local directory on the host
	// <task_dir>/local/
	LocalDir string

	// LogDir is the path to the task's log directory on the host
	// <alloc_dir>/alloc/logs/
	LogDir string

	// SecretsDir is the path to secrets/ directory on the host
	// <task_dir>/secrets/
	SecretsDir string
	// contains filtered or unexported fields
}

TaskDir contains all of the paths relevant to a task. All paths are on the host system so drivers should mount/link into task containers as necessary.

func (*TaskDir) Build added in v0.5.3

func (t *TaskDir) Build(chrootCreated bool, chroot map[string]string, fsi cstructs.FSIsolation) error

Build default directories and permissions in a task directory. chrootCreated allows skipping chroot creation if the caller knows it has already been done.

Jump to

Keyboard shortcuts

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