mirror of
https://github.com/kemko/nomad.git
synced 2026-01-08 11:25:41 +03:00
Symlink on windows
This commit is contained in:
@@ -7,11 +7,17 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
//Path inside container for mounted directory that is shared across tasks in a task group.
|
||||
// SharedAllocContainerPath is the path inside container for mounted
|
||||
// directory shared across tasks in a task group.
|
||||
SharedAllocContainerPath = filepath.Join("c:\\", SharedAllocName)
|
||||
|
||||
//Path inside container for mounted directory for local storage.
|
||||
// TaskLocalContainer is the path inside a container for mounted directory
|
||||
// for local storage.
|
||||
TaskLocalContainerPath = filepath.Join("c:\\", TaskLocal)
|
||||
|
||||
// TaskSecretsContainerPath is the path inside a container for mounted
|
||||
// secrets directory
|
||||
TaskSecretsContainerPath = filepath.Join("c:\\", TaskSecrets)
|
||||
)
|
||||
|
||||
func (d *AllocDir) linkOrCopy(src, dst string, perm os.FileMode) error {
|
||||
@@ -21,11 +27,16 @@ func (d *AllocDir) linkOrCopy(src, dst string, perm os.FileMode) error {
|
||||
// Hardlinks the shared directory. As a side-effect the src and dest directory
|
||||
// must be on the same filesystem.
|
||||
func (d *AllocDir) mount(src, dest string) error {
|
||||
return syscall.Link(src, dest)
|
||||
return os.Symlink(src, dest)
|
||||
}
|
||||
|
||||
func (d *AllocDir) unmount(dir string) error {
|
||||
return syscall.Unlink(dir)
|
||||
p, err := syscall.UTF16PtrFromString(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return syscall.RemoveDirectory(p)
|
||||
}
|
||||
|
||||
// The windows version does nothing currently.
|
||||
|
||||
@@ -438,6 +438,9 @@ func (c *Client) GetAllocFS(allocID string) (allocdir.AllocDirFS, error) {
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("alloc not found")
|
||||
}
|
||||
if ar.ctx == nil {
|
||||
return nil, fmt.Errorf("alloc dir not found")
|
||||
}
|
||||
return ar.ctx.AllocDir, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -156,8 +156,9 @@ func TestClient_ReserveSecretDir(t *testing.T) {
|
||||
|
||||
tsd := secretdir.NewTestSecretDir(t)
|
||||
c.secretDir = tsd
|
||||
expected := 10
|
||||
tsd.MemoryUsed = expected
|
||||
secretUsage := 10
|
||||
expected := c.Node().Reserved.MemoryMB + secretUsage
|
||||
tsd.MemoryUsed = secretUsage
|
||||
|
||||
c.reserveResources()
|
||||
res := c.Node().Reserved
|
||||
|
||||
Reference in New Issue
Block a user