fix crash on upgrade with nil last push field (#1191)
This commit is contained in:
parent
363abafe4b
commit
19323ba4aa
1 changed files with 7 additions and 1 deletions
|
@ -510,12 +510,18 @@ func (a *apic) GetMetrics() (*models.Metrics, error) {
|
|||
if err != nil {
|
||||
return metric, err
|
||||
}
|
||||
var lastpush string
|
||||
for _, machine := range machines {
|
||||
if machine.LastPush == nil {
|
||||
lastpush = time.Time{}.String()
|
||||
} else {
|
||||
lastpush = machine.LastPush.String()
|
||||
}
|
||||
m := &models.MetricsAgentInfo{
|
||||
Version: machine.Version,
|
||||
Name: machine.MachineId,
|
||||
LastUpdate: machine.UpdatedAt.String(),
|
||||
LastPush: machine.LastPush.String(),
|
||||
LastPush: lastpush,
|
||||
}
|
||||
metric.Machines = append(metric.Machines, m)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue