Skip to content

Commit d59eda0

Browse files
strahervagg
authored andcommitted
Enhance node info page with detailed fields (#624)
* Expand node info page * Add message receipt fields and improve table styling * fix lint * Remove message wait tracking from node info page
1 parent 100a849 commit d59eda0

File tree

2 files changed

+176
-40
lines changed

2 files changed

+176
-40
lines changed

web/api/webrpc/cluster.go

Lines changed: 88 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,26 @@ func (a *WebRPC) ClusterTaskHistory(ctx context.Context, limit, offset int) ([]T
140140

141141
type MachineInfo struct {
142142
Info struct {
143-
Name string
144-
Host string
145-
ID int64
146-
LastContact string
147-
CPU int64
148-
Memory int64
149-
GPU int64
150-
Layers string
151-
Unschedulable bool
152-
RunningTasks int
143+
Name string
144+
Host string
145+
ID int64
146+
LastContact string
147+
CPU int64
148+
Memory int64
149+
GPU float64
150+
Layers string
151+
Unschedulable bool
152+
RunningTasks int
153+
Tasks string
154+
Miners string
155+
StartupTime *time.Time
156+
RestartRequest *time.Time
153157
}
154158

155159
// Storage
156160
Storage []struct {
157161
ID string
162+
URLs string
158163
Weight int64
159164
MaxStorage int64
160165
CanSeal bool
@@ -177,34 +182,41 @@ type MachineInfo struct {
177182
ReservedPercent float64
178183
}
179184

180-
/*TotalStorage struct {
181-
MaxStorage int64
182-
UsedStorage int64
183-
184-
MaxSealStorage int64
185-
UsedSealStorage int64
186-
187-
MaxStoreStorage int64
188-
UsedStoreStorage int64
189-
}*/
185+
// Storage URL Liveness
186+
StorageURLs []struct {
187+
StorageID string
188+
URL string
189+
LastChecked time.Time
190+
LastLive *time.Time
191+
LastDead *time.Time
192+
LastDeadReason *string
193+
}
190194

191195
// Tasks
192196
RunningTasks []struct {
193-
ID int64
194-
Task string
195-
Posted string
197+
ID int64
198+
Task string
199+
Posted string
200+
UpdateTime string
201+
InitiatedBy *int64
202+
AddedBy int64
203+
PreviousTask *int64
204+
Retries int64
196205

197206
PoRepSector, PoRepSectorSP *int64
198207
PoRepSectorMiner string
199208
}
200209

201210
FinishedTasks []struct {
202211
ID int64
212+
TaskID int64
203213
Task string
204214
Posted string
205215
Start string
216+
End string
206217
Queued string
207218
Took string
219+
Result bool
208220
Outcome string
209221
Message string
210222
}
@@ -220,8 +232,12 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
220232
hm.ram,
221233
hm.gpu,
222234
hm.unschedulable,
235+
hm.restart_request,
223236
hmd.machine_name,
224-
hmd.layers
237+
hmd.layers,
238+
hmd.tasks,
239+
hmd.miners,
240+
hmd.startup_time
225241
FROM
226242
harmony_machines hm
227243
LEFT JOIN
@@ -241,7 +257,7 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
241257
var m MachineInfo
242258
var lastContact time.Time
243259

244-
if err := rows.Scan(&m.Info.ID, &m.Info.Host, &lastContact, &m.Info.CPU, &m.Info.Memory, &m.Info.GPU, &m.Info.Unschedulable, &m.Info.Name, &m.Info.Layers); err != nil {
260+
if err := rows.Scan(&m.Info.ID, &m.Info.Host, &lastContact, &m.Info.CPU, &m.Info.Memory, &m.Info.GPU, &m.Info.Unschedulable, &m.Info.RestartRequest, &m.Info.Name, &m.Info.Layers, &m.Info.Tasks, &m.Info.Miners, &m.Info.StartupTime); err != nil {
245261
return nil, err
246262
}
247263

@@ -255,7 +271,7 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
255271
}
256272

257273
// query storage info
258-
rows2, err := a.deps.DB.Query(ctx, "SELECT storage_id, weight, max_storage, can_seal, can_store, groups, allow_to, allow_types, deny_types, capacity, available, fs_available, reserved, used, allow_miners, deny_miners, last_heartbeat, heartbeat_err FROM storage_path WHERE urls LIKE '%' || $1 || '%'", summaries[0].Info.Host)
274+
rows2, err := a.deps.DB.Query(ctx, "SELECT storage_id, urls, weight, max_storage, can_seal, can_store, groups, allow_to, allow_types, deny_types, capacity, available, fs_available, reserved, used, allow_miners, deny_miners, last_heartbeat, heartbeat_err FROM storage_path WHERE urls LIKE '%' || $1 || '%'", summaries[0].Info.Host)
259275
if err != nil {
260276
return nil, err
261277
}
@@ -265,6 +281,7 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
265281
for rows2.Next() {
266282
var s struct {
267283
ID string
284+
URLs string
268285
Weight int64
269286
MaxStorage int64
270287
CanSeal bool
@@ -286,7 +303,7 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
286303
UsedPercent float64
287304
ReservedPercent float64
288305
}
289-
if err := rows2.Scan(&s.ID, &s.Weight, &s.MaxStorage, &s.CanSeal, &s.CanStore, &s.Groups, &s.AllowTo, &s.AllowTypes, &s.DenyTypes, &s.Capacity, &s.Available, &s.FSAvailable, &s.Reserved, &s.Used, &s.AllowMiners, &s.DenyMiners, &s.LastHeartbeat, &s.HeartbeatErr); err != nil {
306+
if err := rows2.Scan(&s.ID, &s.URLs, &s.Weight, &s.MaxStorage, &s.CanSeal, &s.CanStore, &s.Groups, &s.AllowTo, &s.AllowTypes, &s.DenyTypes, &s.Capacity, &s.Available, &s.FSAvailable, &s.Reserved, &s.Used, &s.AllowMiners, &s.DenyMiners, &s.LastHeartbeat, &s.HeartbeatErr); err != nil {
290307
return nil, err
291308
}
292309

@@ -297,8 +314,33 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
297314
summaries[0].Storage = append(summaries[0].Storage, s)
298315
}
299316

317+
// query storage URL liveness
318+
rowsURL, err := a.deps.DB.Query(ctx, `SELECT sp.storage_id, spul.url, spul.last_checked, spul.last_live, spul.last_dead, spul.last_dead_reason
319+
FROM storage_path sp
320+
INNER JOIN sector_path_url_liveness spul ON sp.storage_id = spul.storage_id
321+
WHERE sp.urls LIKE '%' || $1 || '%'`, summaries[0].Info.Host)
322+
if err != nil {
323+
return nil, err
324+
}
325+
defer rowsURL.Close()
326+
327+
for rowsURL.Next() {
328+
var sul struct {
329+
StorageID string
330+
URL string
331+
LastChecked time.Time
332+
LastLive *time.Time
333+
LastDead *time.Time
334+
LastDeadReason *string
335+
}
336+
if err := rowsURL.Scan(&sul.StorageID, &sul.URL, &sul.LastChecked, &sul.LastLive, &sul.LastDead, &sul.LastDeadReason); err != nil {
337+
return nil, err
338+
}
339+
summaries[0].StorageURLs = append(summaries[0].StorageURLs, sul)
340+
}
341+
300342
// tasks
301-
rows3, err := a.deps.DB.Query(ctx, "SELECT id, name, posted_time FROM harmony_task WHERE owner_id=$1", summaries[0].Info.ID)
343+
rows3, err := a.deps.DB.Query(ctx, "SELECT id, name, posted_time, update_time, initiated_by, added_by, previous_task, retries FROM harmony_task WHERE owner_id=$1", summaries[0].Info.ID)
302344
if err != nil {
303345
return nil, err
304346
}
@@ -307,20 +349,26 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
307349

308350
for rows3.Next() {
309351
var t struct {
310-
ID int64
311-
Task string
312-
Posted string
352+
ID int64
353+
Task string
354+
Posted string
355+
UpdateTime string
356+
InitiatedBy *int64
357+
AddedBy int64
358+
PreviousTask *int64
359+
Retries int64
313360

314361
PoRepSector *int64
315362
PoRepSectorSP *int64
316363
PoRepSectorMiner string
317364
}
318365

319-
var posted time.Time
320-
if err := rows3.Scan(&t.ID, &t.Task, &posted); err != nil {
366+
var posted, updateTime time.Time
367+
if err := rows3.Scan(&t.ID, &t.Task, &posted, &updateTime, &t.InitiatedBy, &t.AddedBy, &t.PreviousTask, &t.Retries); err != nil {
321368
return nil, err
322369
}
323370
t.Posted = time.Since(posted).Round(time.Second).String()
371+
t.UpdateTime = time.Since(updateTime).Round(time.Second).String()
324372

325373
{
326374
// try to find in the porep pipeline
@@ -361,7 +409,7 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
361409
summaries[0].Info.RunningTasks++
362410
}
363411

364-
rows5, err := a.deps.DB.Query(ctx, `SELECT name, task_id, posted, work_start, work_end, result, err FROM harmony_task_history WHERE completed_by_host_and_port = $1 ORDER BY work_end DESC LIMIT 15`, summaries[0].Info.Host)
412+
rows5, err := a.deps.DB.Query(ctx, `SELECT id, name, task_id, posted, work_start, work_end, result, err FROM harmony_task_history WHERE completed_by_host_and_port = $1 ORDER BY work_end DESC LIMIT 15`, summaries[0].Info.Host)
365413
if err != nil {
366414
return nil, err
367415
}
@@ -370,30 +418,32 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
370418
for rows5.Next() {
371419
var ft struct {
372420
ID int64
421+
TaskID int64
373422
Task string
374423
Posted string
375424
Start string
425+
End string
376426
Queued string
377427
Took string
428+
Result bool
378429
Outcome string
379-
380430
Message string
381431
}
382432

383433
var posted, start, end time.Time
384-
var result bool
385-
if err := rows5.Scan(&ft.Task, &ft.ID, &posted, &start, &end, &result, &ft.Message); err != nil {
434+
if err := rows5.Scan(&ft.ID, &ft.Task, &ft.TaskID, &posted, &start, &end, &ft.Result, &ft.Message); err != nil {
386435
return nil, err
387436
}
388437

389438
ft.Outcome = "Success"
390-
if !result {
439+
if !ft.Result {
391440
ft.Outcome = "Failed"
392441
}
393442

394443
// Format the times and durations
395444
ft.Posted = posted.Format("02 Jan 06 15:04 MST")
396445
ft.Start = start.Format("02 Jan 06 15:04 MST")
446+
ft.End = end.Format("02 Jan 06 15:04 MST")
397447
ft.Queued = start.Sub(posted).Round(time.Second).String()
398448
ft.Took = end.Sub(start).Round(time.Second).String()
399449

0 commit comments

Comments
 (0)