mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
driver: add pre09 migration logic
This commit is contained in:
36
client/allocdir/task_dir_linux.go
Normal file
36
client/allocdir/task_dir_linux.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package allocdir
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
)
|
||||
|
||||
// unmountSpecialDirs unmounts the dev and proc file system from the chroot. No
|
||||
// error is returned if the directories do not exist or have already been
|
||||
// unmounted.
|
||||
func (t *TaskDir) unmountSpecialDirs() error {
|
||||
errs := new(multierror.Error)
|
||||
dev := filepath.Join(t.Dir, "dev")
|
||||
if pathExists(dev) {
|
||||
if err := unlinkDir(dev); err != nil {
|
||||
errs = multierror.Append(errs, fmt.Errorf("Failed to unmount dev %q: %v", dev, err))
|
||||
} else if err := os.RemoveAll(dev); err != nil {
|
||||
errs = multierror.Append(errs, fmt.Errorf("Failed to delete dev directory %q: %v", dev, err))
|
||||
}
|
||||
}
|
||||
|
||||
// Unmount proc.
|
||||
proc := filepath.Join(t.Dir, "proc")
|
||||
if pathExists(proc) {
|
||||
if err := unlinkDir(proc); err != nil {
|
||||
errs = multierror.Append(errs, fmt.Errorf("Failed to unmount proc %q: %v", proc, err))
|
||||
} else if err := os.RemoveAll(proc); err != nil {
|
||||
errs = multierror.Append(errs, fmt.Errorf("Failed to delete proc directory %q: %v", dev, err))
|
||||
}
|
||||
}
|
||||
|
||||
return errs.ErrorOrNil()
|
||||
}
|
||||
Reference in New Issue
Block a user