@@ -140,21 +140,26 @@ func (a *WebRPC) ClusterTaskHistory(ctx context.Context, limit, offset int) ([]T
140
140
141
141
type MachineInfo struct {
142
142
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
153
157
}
154
158
155
159
// Storage
156
160
Storage []struct {
157
161
ID string
162
+ URLs string
158
163
Weight int64
159
164
MaxStorage int64
160
165
CanSeal bool
@@ -177,34 +182,41 @@ type MachineInfo struct {
177
182
ReservedPercent float64
178
183
}
179
184
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
+ }
190
194
191
195
// Tasks
192
196
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
196
205
197
206
PoRepSector , PoRepSectorSP * int64
198
207
PoRepSectorMiner string
199
208
}
200
209
201
210
FinishedTasks []struct {
202
211
ID int64
212
+ TaskID int64
203
213
Task string
204
214
Posted string
205
215
Start string
216
+ End string
206
217
Queued string
207
218
Took string
219
+ Result bool
208
220
Outcome string
209
221
Message string
210
222
}
@@ -220,8 +232,12 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
220
232
hm.ram,
221
233
hm.gpu,
222
234
hm.unschedulable,
235
+ hm.restart_request,
223
236
hmd.machine_name,
224
- hmd.layers
237
+ hmd.layers,
238
+ hmd.tasks,
239
+ hmd.miners,
240
+ hmd.startup_time
225
241
FROM
226
242
harmony_machines hm
227
243
LEFT JOIN
@@ -241,7 +257,7 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
241
257
var m MachineInfo
242
258
var lastContact time.Time
243
259
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 {
245
261
return nil , err
246
262
}
247
263
@@ -255,7 +271,7 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
255
271
}
256
272
257
273
// 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 )
259
275
if err != nil {
260
276
return nil , err
261
277
}
@@ -265,6 +281,7 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
265
281
for rows2 .Next () {
266
282
var s struct {
267
283
ID string
284
+ URLs string
268
285
Weight int64
269
286
MaxStorage int64
270
287
CanSeal bool
@@ -286,7 +303,7 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
286
303
UsedPercent float64
287
304
ReservedPercent float64
288
305
}
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 {
290
307
return nil , err
291
308
}
292
309
@@ -297,8 +314,33 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
297
314
summaries [0 ].Storage = append (summaries [0 ].Storage , s )
298
315
}
299
316
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
+
300
342
// 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 )
302
344
if err != nil {
303
345
return nil , err
304
346
}
@@ -307,20 +349,26 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
307
349
308
350
for rows3 .Next () {
309
351
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
313
360
314
361
PoRepSector * int64
315
362
PoRepSectorSP * int64
316
363
PoRepSectorMiner string
317
364
}
318
365
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 {
321
368
return nil , err
322
369
}
323
370
t .Posted = time .Since (posted ).Round (time .Second ).String ()
371
+ t .UpdateTime = time .Since (updateTime ).Round (time .Second ).String ()
324
372
325
373
{
326
374
// try to find in the porep pipeline
@@ -361,7 +409,7 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
361
409
summaries [0 ].Info .RunningTasks ++
362
410
}
363
411
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 )
365
413
if err != nil {
366
414
return nil , err
367
415
}
@@ -370,30 +418,32 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
370
418
for rows5 .Next () {
371
419
var ft struct {
372
420
ID int64
421
+ TaskID int64
373
422
Task string
374
423
Posted string
375
424
Start string
425
+ End string
376
426
Queued string
377
427
Took string
428
+ Result bool
378
429
Outcome string
379
-
380
430
Message string
381
431
}
382
432
383
433
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 {
386
435
return nil , err
387
436
}
388
437
389
438
ft .Outcome = "Success"
390
- if ! result {
439
+ if ! ft . Result {
391
440
ft .Outcome = "Failed"
392
441
}
393
442
394
443
// Format the times and durations
395
444
ft .Posted = posted .Format ("02 Jan 06 15:04 MST" )
396
445
ft .Start = start .Format ("02 Jan 06 15:04 MST" )
446
+ ft .End = end .Format ("02 Jan 06 15:04 MST" )
397
447
ft .Queued = start .Sub (posted ).Round (time .Second ).String ()
398
448
ft .Took = end .Sub (start ).Round (time .Second ).String ()
399
449
0 commit comments