mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 18:05:42 +03:00
Improve the error messages when obtaining node and alloc stats
This commit is contained in:
@@ -135,7 +135,7 @@ func (c *AllocStatusCommand) Run(args []string) int {
|
||||
stats, statsErr = client.Allocations().Stats(alloc, nil)
|
||||
if statsErr != nil {
|
||||
c.Ui.Output("")
|
||||
c.Ui.Error(fmt.Sprintf("couldn't retreive stats: %v", statsErr))
|
||||
c.Ui.Error(fmt.Sprintf("couldn't retrieve stats (HINT: ensure Client.Advertise.HTTP is set): %v", statsErr))
|
||||
}
|
||||
|
||||
// Format the allocation data
|
||||
|
||||
@@ -222,6 +222,10 @@ func (c *NodeStatusCommand) Run(args []string) int {
|
||||
func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int {
|
||||
// Get the host stats
|
||||
hostStats, nodeStatsErr := client.Nodes().Stats(node.ID, nil)
|
||||
if nodeStatsErr != nil {
|
||||
c.Ui.Output("")
|
||||
c.Ui.Error(fmt.Sprintf("error fetching node stats (HINT: ensure Client.Advertise.HTTP is set): %v", nodeStatsErr))
|
||||
}
|
||||
|
||||
// Format the header output
|
||||
basic := []string{
|
||||
@@ -257,6 +261,10 @@ func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int {
|
||||
}
|
||||
|
||||
hostResources, err := getHostResources(hostStats, node)
|
||||
if err != nil {
|
||||
c.Ui.Output("")
|
||||
c.Ui.Error(fmt.Sprintf("error fetching node stats (HINT: ensure Client.Advertise.HTTP is set): %v", err))
|
||||
}
|
||||
if err == nil {
|
||||
c.Ui.Output(c.Colorize().Color("\n[bold]Host Resource Utilization[reset]"))
|
||||
c.Ui.Output(formatList(hostResources))
|
||||
@@ -286,10 +294,6 @@ func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int {
|
||||
if c.verbose {
|
||||
c.formatAttributes(node)
|
||||
}
|
||||
if nodeStatsErr != nil {
|
||||
c.Ui.Output("")
|
||||
c.Ui.Error(fmt.Sprintf("error fetching node stats: %v", nodeStatsErr))
|
||||
}
|
||||
return 0
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user