mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
remove always false parameter
Simplify allocDir.Build() function to avoid depending on client/structs, and remove a parameter that's always set to `false`. The motivation here is to avoid a dependency cycle between drivers/cstructs and alloc_dir.
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
)
|
||||
|
||||
// TaskDir contains all of the paths relevant to a task. All paths are on the
|
||||
@@ -75,7 +74,7 @@ func (t *TaskDir) Copy() *TaskDir {
|
||||
// Build default directories and permissions in a task directory. chrootCreated
|
||||
// allows skipping chroot creation if the caller knows it has already been
|
||||
// done.
|
||||
func (t *TaskDir) Build(chrootCreated bool, chroot map[string]string, fsi cstructs.FSIsolation) error {
|
||||
func (t *TaskDir) Build(createChroot bool, chroot map[string]string) error {
|
||||
if err := os.MkdirAll(t.Dir, 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -110,7 +109,7 @@ func (t *TaskDir) Build(chrootCreated bool, chroot map[string]string, fsi cstruc
|
||||
// Image based isolation will bind the shared alloc dir in the driver.
|
||||
// If there's no isolation the task will use the host path to the
|
||||
// shared alloc dir.
|
||||
if fsi == cstructs.FSIsolationChroot {
|
||||
if createChroot {
|
||||
// If the path doesn't exist OR it exists and is empty, link it
|
||||
empty, _ := pathEmpty(t.SharedTaskDir)
|
||||
if !pathExists(t.SharedTaskDir) || empty {
|
||||
@@ -130,8 +129,8 @@ func (t *TaskDir) Build(chrootCreated bool, chroot map[string]string, fsi cstruc
|
||||
}
|
||||
|
||||
// Build chroot if chroot filesystem isolation is going to be used
|
||||
if fsi == cstructs.FSIsolationChroot {
|
||||
if err := t.buildChroot(chrootCreated, chroot); err != nil {
|
||||
if createChroot {
|
||||
if err := t.buildChroot(chroot); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -142,15 +141,9 @@ func (t *TaskDir) Build(chrootCreated bool, chroot map[string]string, fsi cstruc
|
||||
// buildChroot takes a mapping of absolute directory or file paths on the host
|
||||
// to their intended, relative location within the task directory. This
|
||||
// attempts hardlink and then defaults to copying. If the path exists on the
|
||||
// host and can't be embedded an error is returned. If chrootCreated is true
|
||||
// skip expensive embedding operations and only ephemeral operations (eg
|
||||
// mounting /dev) are done.
|
||||
func (t *TaskDir) buildChroot(chrootCreated bool, entries map[string]string) error {
|
||||
if !chrootCreated {
|
||||
// Link/copy chroot entries
|
||||
return t.embedDirs(entries)
|
||||
}
|
||||
return nil
|
||||
// host and can't be embedded an error is returned.
|
||||
func (t *TaskDir) buildChroot(entries map[string]string) error {
|
||||
return t.embedDirs(entries)
|
||||
}
|
||||
|
||||
func (t *TaskDir) embedDirs(entries map[string]string) error {
|
||||
|
||||
Reference in New Issue
Block a user