mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Testing if stats is present and it is a map
This commit is contained in:
@@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -68,6 +69,10 @@ func (c *AgentCheckCommand) Run(args []string) int {
|
||||
c.Ui.Output(fmt.Sprintf("unable to query agent info: %v", err))
|
||||
return HealthCritical
|
||||
}
|
||||
if stats, ok := info["stats"]; !ok && (reflect.TypeOf(stats).Kind() == reflect.Map) {
|
||||
c.Ui.Error("error getting stats from the agent api")
|
||||
return 1
|
||||
}
|
||||
if _, ok := info["stats"]["nomad"]; ok {
|
||||
return c.checkServerHealth(info["stats"], minPeers)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user