Merge pull request #902 from hashicorp/f-fs-error

Improved the error related to fs commands
This commit is contained in:
Diptanu Choudhury
2016-03-10 14:08:33 -08:00
3 changed files with 21 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {