Skip to content

Commit

Permalink
feat: (FOUNDENG-344) Change enroot to use /var/tmp as localTmp direct…
Browse files Browse the repository at this point in the history
…ory (#631)

* use /var/tmp as tmpfs
Co-authored-by: Pankaj Mandal <[email protected]>
  • Loading branch information
pankaj-mandal authored and determined-ci committed Apr 18, 2024
1 parent 3aeefcb commit 173638e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
21 changes: 20 additions & 1 deletion master/pkg/tasks/dispatcher_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ func (t *TaskSpec) ToDispatcherManifest(

mounts, userWantsDirMountedOnTmp := getDataVolumes(t.Mounts)

if containerRunType == enroot {
mounts = addTmpFs(mounts, "varTmp", varTmp)
}

/*
* We need a per-container-private link directory to host /run/determined.
* This is the target of a number of softlinks that are remapped to per-container
Expand All @@ -162,7 +166,7 @@ func (t *TaskSpec) ToDispatcherManifest(
*/
localTmp := "/"
if containerRunType == enroot {
localTmp = tmp
localTmp = varTmp
}

// Use the specified workDir if it is user-specified.
Expand Down Expand Up @@ -722,6 +726,21 @@ func getDataVolumes(mounts []mount.Mount) ([]launcher.Data, bool) {
return volumes, userWantsDirMountedOnTmp
}

// Used for creating a tmpfs mount type at the target location.
func addTmpFs(volumes []launcher.Data, name string, target string) []launcher.Data {
volume := *launcher.NewData()
volume.SetName(name)
volume.SetSource("tmpfs")

/*
* Set target and add a mount option to enable target directory creation,
* if it did not exist
*/
volume.SetTarget(target + ":x-create=dir")
volumes = append(volumes, volume)
return volumes
}

// Create a softlink archive entry for the specified file name in the
// '/run/determined' directory to the local container temp version.
// Provide a localTmp directory to redirect it elsewhere (must end in /).
Expand Down
12 changes: 12 additions & 0 deletions master/pkg/tasks/dispatcher_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,18 @@ func Test_getDataVolumns(t *testing.T) {
}
}

func Test_addTmpFs(t *testing.T) {
arg := []mount.Mount{}
volumes, _ := getDataVolumes(arg)
name := "varTmp"
target := "/var/tmp"
volumes = addTmpFs(volumes, name, target)
v := volumes[0]
assert.Equal(t, *v.Name, "varTmp")
assert.Equal(t, *v.Source, "tmpfs")
assert.Equal(t, *v.Target, "/var/tmp:x-create=dir")
}

func Test_getPayloadName(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit 173638e

Please sign in to comment.