lpweb: Pipeline view

This commit is contained in:
Łukasz Magiera 2024-01-12 16:16:35 +01:00
parent afc124ab2a
commit 0bd4d7dd8b
6 changed files with 133 additions and 24 deletions

View File

@ -173,6 +173,7 @@ retryRecordCompletion:
cm, err := h.TaskEngine.db.BeginTransaction(h.TaskEngine.ctx, func(tx *harmonydb.Tx) (bool, error) {
var postedTime time.Time
err := tx.QueryRow(`SELECT posted_time FROM harmony_task WHERE id=$1`, tID).Scan(&postedTime)
if err != nil {
return false, fmt.Errorf("could not log completion: %w ", err)
}

View File

@ -32,6 +32,7 @@ func Routes(r *mux.Router, deps *deps.Deps) error {
r.HandleFunc("/simpleinfo/machines", a.indexMachines)
r.HandleFunc("/simpleinfo/tasks", a.indexTasks)
r.HandleFunc("/simpleinfo/taskhistory", a.indexTasksHistory)
r.HandleFunc("/simpleinfo/pipeline-porep", a.indexPipelinePorep)
return nil
}

View File

@ -3,6 +3,7 @@ package hapi
import (
"context"
"github.com/filecoin-project/lotus/api/v1api"
"golang.org/x/xerrors"
"html/template"
"net/http"
"os"
@ -81,6 +82,17 @@ func (a *app) indexTasksHistory(w http.ResponseWriter, r *http.Request) {
a.executeTemplate(w, "cluster_task_history", s)
}
func (a *app) indexPipelinePorep(w http.ResponseWriter, r *http.Request) {
s, err := a.porepPipelineSummary(r.Context())
if err != nil {
log.Errorf("porep pipeline summary: %v", err)
http.Error(w, "internal server error", http.StatusInternalServerError)
return
}
a.executeTemplate(w, "pipeline_porep", s)
}
var templateDev = os.Getenv("LOTUS_WEB_DEV") == "1"
func (a *app) executeTemplate(w http.ResponseWriter, name string, data interface{}) {
@ -111,7 +123,7 @@ type taskHistorySummary struct {
Name string
TaskID int64
Posted, Start, End string
Posted, Start, Queued, Took string
Result bool
Err string
@ -181,11 +193,67 @@ func (a *app) clusterTaskHistorySummary(ctx context.Context) ([]taskHistorySumma
return nil, err // Handle error
}
t.Posted = posted.Round(time.Second).Format("02 Jan 06 15:04")
t.Start = start.Round(time.Second).Format("02 Jan 06 15:04")
t.End = end.Round(time.Second).Format("02 Jan 06 15:04")
t.Posted = posted.Local().Round(time.Second).Format("02 Jan 06 15:04")
t.Start = start.Local().Round(time.Second).Format("02 Jan 06 15:04")
//t.End = end.Local().Round(time.Second).Format("02 Jan 06 15:04")
t.Queued = start.Sub(posted).Round(time.Second).String()
if t.Queued == "0s" {
t.Queued = start.Sub(posted).Round(time.Millisecond).String()
}
t.Took = end.Sub(start).Round(time.Second).String()
if t.Took == "0s" {
t.Took = end.Sub(start).Round(time.Millisecond).String()
}
summaries = append(summaries, t)
}
return summaries, nil
}
type porepPipelineSummary struct {
Actor string
CountSDR int
CountTrees int
CountPrecommitMsg int
CountWaitSeed int
CountPoRep int
CountCommitMsg int
CountDone int
CountFailed int
}
func (a *app) porepPipelineSummary(ctx context.Context) ([]porepPipelineSummary, error) {
rows, err := a.db.Query(ctx, `
SELECT
sp_id,
COUNT(*) FILTER (WHERE after_sdr = true AND after_tree_d = false) as CountSDR,
COUNT(*) FILTER (WHERE (after_tree_d = true OR after_tree_c = true OR after_tree_r = true) AND after_precommit_msg = false) as CountTrees,
COUNT(*) FILTER (WHERE after_precommit_msg = true AND after_precommit_msg_success = false) as CountPrecommitMsg,
COUNT(*) FILTER (WHERE after_precommit_msg_success = true AND after_porep = false) as CountWaitSeed,
COUNT(*) FILTER (WHERE after_porep = true AND after_commit_msg = false) as CountPoRep,
COUNT(*) FILTER (WHERE after_commit_msg = true AND after_commit_msg_success = false) as CountCommitMsg,
COUNT(*) FILTER (WHERE after_commit_msg_success = true) as CountDone,
COUNT(*) FILTER (WHERE failed = true) as CountFailed
FROM
sectors_sdr_pipeline
GROUP BY sp_id`)
if err != nil {
return nil, xerrors.Errorf("query: %w", err)
}
defer rows.Close()
var summaries []porepPipelineSummary
for rows.Next() {
var summary porepPipelineSummary
if err := rows.Scan(&summary.Actor, &summary.CountSDR, &summary.CountTrees, &summary.CountPrecommitMsg, &summary.CountWaitSeed, &summary.CountPoRep, &summary.CountCommitMsg, &summary.CountDone, &summary.CountFailed); err != nil {
return nil, xerrors.Errorf("scan: %w", err)
}
summary.Actor = "f0" + summary.Actor
summaries = append(summaries, summary)
}
return summaries, nil
}

View File

@ -6,7 +6,8 @@
<td>{{.CompletedBy}}</td>
<td>{{.Posted}}</td>
<td>{{.Start}}</td>
<td>{{.End}}</td>
<td>{{.Queued}}</td>
<td>{{.Took}}</td>
<td>{{if .Result}}<span class="success">success</span>{{else}}<span class="error">error</span>{{end}}</td>
<td style="max-width: 25vh">
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis" title="{{.Err}}">

View File

@ -0,0 +1,15 @@
{{define "pipeline_porep"}}
{{range .}}
<tr>
<td><b>{{.Actor}}</b></td>
<td {{if ne .CountSDR 0}}class="success"{{end}}>{{.CountSDR}}</td>
<td {{if ne .CountTrees 0}}class="success"{{end}}>{{.CountTrees}}</td>
<td {{if ne .CountPrecommitMsg 0}}class="success"{{end}}>{{.CountPrecommitMsg}}</td>
<td {{if ne .CountWaitSeed 0}}class="success"{{end}}>{{.CountWaitSeed}}</td>
<td {{if ne .CountPoRep 0}}class="success"{{end}}>{{.CountPoRep}}</td>
<td {{if ne .CountCommitMsg 0}}class="success"{{end}}>{{.CountCommitMsg}}</td>
<td>{{.CountDone}}</td>
<td>{{.CountFailed}}</td>
</tr>
{{end}}
{{end}}

View File

@ -3,6 +3,7 @@
<title>Lotus Provider Cluster Overview</title>
<script src="https://unpkg.com/htmx.org@1.9.5" integrity="sha384-xcuj3WpfgjlKF+FXhSQFQ0ZNr39ln+hwjN3npfM9VBnUskLolQAcN80McRIVOPuO" crossorigin="anonymous"></script>
<script type="module" src="chain-connectivity.js"></script>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/hack-font@3.3.0/build/web/hack-subset.css'>
<style>
html, body {
background: #0f0f0f;
@ -10,7 +11,7 @@
padding: 0;
margin: 0;
font-family: monospace;
font-family: 'Hack', monospace;
}
table td, table th {
@ -54,7 +55,7 @@
}
.success {
color: green;
color: greenyellow;
}
.warning {
color: yellow;
@ -121,22 +122,6 @@
<chain-connectivity></chain-connectivity>
</div>
<hr>
<div class="info-block">
<h2>Actor Summary</h2>
<table>
<thead>
<tr>
<th>Address</th>
<th>Config Layers</th>
<th>QaP</th>
<th>Deadlines</th>
</tr>
</thead>
<tbody hx-get="/hapi/simpleinfo/actorsummary" hx-trigger="load,every 5s">
</tbody>
</table>
</div>
<hr>
<div class="info-block">
<h2>Cluster Machines</h2>
<table>
@ -153,6 +138,43 @@
</table>
</div>
<hr>
<div class="info-block">
<h2>PoRep Pipeline</h2>
<table>
<thead>
<tr>
<th>Address</th>
<th>SDR</th>
<th>Trees</th>
<th>Precommit Msg</th>
<th>Wait Seed</th>
<th>PoRep</th>
<th>Commit Msg</th>
<th>Done</th>
<th>Failed</th>
</tr>
</thead>
<tbody hx-get="/hapi/simpleinfo/pipeline-porep" hx-trigger="load,every 5s">
</tbody>
</table>
</div>
<hr>
<div class="info-block">
<h2>Actor Summary</h2>
<table>
<thead>
<tr>
<th>Address</th>
<th>Config Layers</th>
<th>QaP</th>
<th>Deadlines</th>
</tr>
</thead>
<tbody hx-get="/hapi/simpleinfo/actorsummary" hx-trigger="load,every 5s">
</tbody>
</table>
</div>
<hr>
<div class="info-block">
<h2>Recently Finished Tasks</h2>
<table>
@ -163,7 +185,8 @@
<th>Executor</th>
<th>Posted</th>
<th>Start</th>
<th>End</th>
<th>Queued</th>
<th>Took</th>
<th>Outcome</th>
<th>Message</th>
</tr>