Skip to content

Commit

Permalink
client: cleanup empty task directory when using unveil filesystem iso…
Browse files Browse the repository at this point in the history
…lation (#23237)

This PR fixes a bug where Nomad client would leave behind an empty directory
created on behalf of tasks making use of the unveil filesystem isolation
mode (i.e. using exec2 task driver). Once unmounting is complete, we should
remember to also delete the directory.

Fixes #22433
  • Loading branch information
shoenig authored Jun 6, 2024
1 parent 71fd5c2 commit 45da80b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/23237.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
client: Fixed a bug where empty task directories would be left behind
```
8 changes: 8 additions & 0 deletions client/allocdir/task_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,14 @@ func (t *TaskDir) Unmount() error {
}
}

// delete the task's parent alloc mounts dir if it exists
if dir := filepath.Dir(t.MountsAllocDir); pathExists(dir) {
if err := os.RemoveAll(dir); err != nil {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("failed to remove the task alloc mounts dir %q: %w", dir, err))
}
}

if pathExists(t.SecretsDir) {
if err := removeSecretDir(t.SecretsDir); err != nil {
mErr = multierror.Append(mErr,
Expand Down

0 comments on commit 45da80b

Please sign in to comment.