Skip to content

Commit 8637ab6

Browse files
committed
allocRunner: fail alloc if allocDir is inaccessible
1 parent 7e57f74 commit 8637ab6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

client/allocrunner/alloc_runner.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"context"
88
"fmt"
99
"maps"
10+
"os"
1011
"sync"
1112
"time"
1213

@@ -472,6 +473,13 @@ func (ar *allocRunner) GetAllocDir() allocdir.Interface {
472473
// Restore state from database. Must be called after NewAllocRunner but before
473474
// Run.
474475
func (ar *allocRunner) Restore() error {
476+
// We should not carry on to restoring an allocation whose directory is
477+
// inaccessible. This can happen if allocation storage is ephemeral, e.g.
478+
// a tmpfs or cloud local SSDs.
479+
if _, err := os.Stat(ar.allocDir.AllocDirPath()); err != nil {
480+
return fmt.Errorf("allocation directory is inacessible: %w", err)
481+
}
482+
475483
// Retrieve deployment status to avoid reseting it across agent
476484
// restarts. Once a deployment status is set Nomad no longer monitors
477485
// alloc health, so we must persist deployment state across restarts.

0 commit comments

Comments
 (0)