Documentation ¶
Index ¶
- Variables
- func SnapshotErrorFilename(allocID string) string
- type AllocDir
- func (d *AllocDir) BlockUntilExists(ctx context.Context, path string) (chan error, error)
- func (d *AllocDir) Build() error
- func (d *AllocDir) ChangeEvents(ctx context.Context, path string, curOffset int64) (*watch.FileChanges, error)
- func (d *AllocDir) Copy() *AllocDir
- func (d *AllocDir) Destroy() error
- func (d *AllocDir) List(path string) ([]*cstructs.AllocFileInfo, error)
- func (d *AllocDir) Move(other *AllocDir, tasks []*structs.Task) error
- func (d *AllocDir) NewTaskDir(name string) *TaskDir
- func (d *AllocDir) ReadAt(path string, offset int64) (io.ReadCloser, error)
- func (d *AllocDir) Snapshot(w io.Writer) error
- func (d *AllocDir) Stat(path string) (*cstructs.AllocFileInfo, error)
- func (d *AllocDir) UnmountAll() error
- type AllocDirFS
- type TaskDir
Constants ¶
This section is empty.
Variables ¶
var ( // SnapshotErrorTime is the sentinel time that will be used on the // error file written by Snapshot when it encounters as error. SnapshotErrorTime = time.Date(2000, 0, 0, 0, 0, 0, 0, time.UTC) SharedAllocName = "alloc" // Name of the directory where logs of Tasks are written LogDirName = "logs" // included in snapshots. SharedDataDir = "data" // TmpDirName is the name of the temporary directory in each alloc and // task. TmpDirName = "tmp" SharedAllocDirs = []string{LogDirName, TmpDirName, 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 = map[string]os.FileMode{TmpDirName: os.ModeSticky | 0777} // AllocGRPCSocket is the path relative to the task dir root for the // unix socket connected to Consul's gRPC endpoint. AllocGRPCSocket = filepath.Join(SharedAllocName, TmpDirName, "consul_grpc.sock") // AllocHTTPSocket is the path relative to the task dir root for the unix // socket connected to Consul's HTTP endpoint. AllocHTTPSocket = filepath.Join(SharedAllocName, TmpDirName, "consul_http.sock") )
var ( // 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 ¶
func SnapshotErrorFilename ¶ added in v0.7.1
SnapshotErrorFilename returns the filename which will exist if there was an error snapshotting a tar.
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 // group. SharedDir string // TaskDirs is a mapping of task names to their non-shared directory. TaskDirs map[string]*TaskDir // contains filtered or unexported fields }
AllocDir allows creating, destroying, and accessing an allocation's directory. All methods are safe for concurrent use.
func NewAllocDir ¶
NewAllocDir initializes the AllocDir struct with allocDir as base path for the allocation directory.
func TestAllocDir ¶ added in v0.10.0
TestAllocDir returns a built alloc dir in a temporary directory and cleanup func.
func (*AllocDir) BlockUntilExists ¶ added in v0.4.1
BlockUntilExists blocks until the passed file relative the allocation directory exists. The block can be cancelled with the passed context.
func (*AllocDir) ChangeEvents ¶ added in v0.4.1
func (d *AllocDir) ChangeEvents(ctx context.Context, path string, curOffset int64) (*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 context is used to clean up the watch.
func (*AllocDir) Copy ¶ added in v0.6.0
Copy an AllocDir and all of its TaskDirs. Returns nil if AllocDir is nil.
func (*AllocDir) List ¶ added in v0.3.0
func (d *AllocDir) List(path string) ([]*cstructs.AllocFileInfo, error)
List returns the list of files at a path relative to the alloc dir
func (*AllocDir) Move ¶ added in v0.5.0
Move other alloc directory's shared path and local dir to this alloc dir.
func (*AllocDir) NewTaskDir ¶ added in v0.5.3
NewTaskDir creates a new TaskDir and adds it to the AllocDirs TaskDirs map.
func (*AllocDir) ReadAt ¶ added in v0.3.0
ReadAt returns a reader for a file at the path relative to the alloc dir
func (*AllocDir) Snapshot ¶ added in v0.5.0
Snapshot creates an archive of the files and directories in the data dir of the allocation and the task local directories
Since a valid tar may have been written even when an error occurs, a special file "NOMAD-${ALLOC_ID}-ERROR.log" will be appended to the tar with the error message as the contents.
func (*AllocDir) Stat ¶ added in v0.3.0
func (d *AllocDir) Stat(path string) (*cstructs.AllocFileInfo, error)
Stat returns information about the file at a path relative to the alloc dir
func (*AllocDir) UnmountAll ¶ added in v0.3.0
UnmountAll linked/mounted directories in task dirs.
type AllocDirFS ¶ added in v0.3.0
type AllocDirFS interface { List(path string) ([]*cstructs.AllocFileInfo, error) Stat(path string) (*cstructs.AllocFileInfo, error) ReadAt(path string, offset int64) (io.ReadCloser, error) Snapshot(w io.Writer) error BlockUntilExists(ctx context.Context, path string) (chan error, error) ChangeEvents(ctx context.Context, path string, curOffset int64) (*watch.FileChanges, error) }
AllocDirFS exposes file operations on the alloc dir
type TaskDir ¶ added in v0.5.3
type TaskDir struct { // AllocDir is the path to the alloc directory on the host AllocDir string // Dir is the path to Task directory on the host Dir string // <alloc_dir>/alloc/ SharedAllocDir string // 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.