diff --git a/command/fs_cat.go b/command/fs_cat.go index 974e2d5e3..9a7616ab0 100644 --- a/command/fs_cat.go +++ b/command/fs_cat.go @@ -114,6 +114,13 @@ func (f *FSCatCommand) Run(args []string) int { } } + if alloc.DesiredStatus == "failed" { + allocID := limit(alloc.ID, length) + msg := fmt.Sprintf(`The allocation %q failed to be placed. To see the cause, run: +nomad alloc-status %s`, allocID, allocID) + f.Ui.Error(msg) + return 0 + } // Stat the file to find it's size file, _, err := client.AllocFS().Stat(alloc, path, nil) if err != nil { diff --git a/command/fs_ls.go b/command/fs_ls.go index 65766bff1..9329f1dd2 100644 --- a/command/fs_ls.go +++ b/command/fs_ls.go @@ -120,6 +120,13 @@ func (f *FSListCommand) Run(args []string) int { } } + if alloc.DesiredStatus == "failed" { + allocID := limit(alloc.ID, length) + msg := fmt.Sprintf(`The allocation %q failed to be placed. To see the cause, run: +nomad alloc-status %s`, allocID, allocID) + f.Ui.Error(msg) + return 0 + } // Get the file at the given path files, _, err := client.AllocFS().List(alloc, path, nil) if err != nil { diff --git a/command/fs_stat.go b/command/fs_stat.go index 581f27246..9c163f803 100644 --- a/command/fs_stat.go +++ b/command/fs_stat.go @@ -119,6 +119,13 @@ func (f *FSStatCommand) Run(args []string) int { } } + if alloc.DesiredStatus == "failed" { + allocID := limit(alloc.ID, length) + msg := fmt.Sprintf(`The allocation %q failed to be placed. To see the cause, run: +nomad alloc-status %s`, allocID, allocID) + f.Ui.Error(msg) + return 0 + } // Get the file information file, _, err := client.AllocFS().Stat(alloc, path, nil) if err != nil {