Skip to content

Commit

Permalink
restart button for sectors (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr authored Oct 9, 2024
1 parent a316495 commit 8257357
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
27 changes: 27 additions & 0 deletions web/api/webrpc/sector.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/curio/lib/paths"
"github.com/filecoin-project/curio/lib/storiface"
Expand All @@ -30,6 +31,7 @@ type SectorInfo struct {
TaskHistory []TaskHistory

Resumable bool
Restart bool
}

type SectorInfoTaskSummary struct {
Expand Down Expand Up @@ -118,6 +120,7 @@ func (a *WebRPC) SectorInfo(ctx context.Context, sp string, intid int64) (*Secto
task_id_tree_d, after_tree_d,
task_id_tree_c, after_tree_c,
task_id_tree_r, after_tree_r,
task_id_synth, after_synth,
task_id_precommit_msg, after_precommit_msg,
after_precommit_msg_success, seed_epoch,
task_id_porep, porep_proof, after_porep,
Expand Down Expand Up @@ -407,6 +410,7 @@ func (a *WebRPC) SectorInfo(ctx context.Context, sp string, intid int64) (*Secto
TaskHistory: th,

Resumable: hasAnyStuckTask,
Restart: hasAnyStuckTask && !sle.AfterSynthetic, // Should be stuck and not be past SyntheticProofs
}, nil
}

Expand Down Expand Up @@ -438,3 +442,26 @@ func (a *WebRPC) SectorRemove(ctx context.Context, spid, id int64) error {

return nil
}

func (a *WebRPC) SectorRestart(ctx context.Context, spid, id int64) error {
_, err := a.deps.DB.Exec(ctx, `UPDATE sectors_sdr_pipeline SET after_sdr = false, after_tree_d = false, after_tree_c = false,
after_tree_r = false WHERE sp_id = $1 AND sector_number = $2`, spid, id)
if err != nil {
return xerrors.Errorf("failed to reset sector state: %w", err)
}

err = a.deps.Stor.Remove(ctx, abi.SectorID{Miner: abi.ActorID(spid), Number: abi.SectorNumber(id)}, storiface.FTCache, true, nil)
if err != nil {
return xerrors.Errorf("failed to remove cache file: %w", err)
}
err = a.deps.Stor.Remove(ctx, abi.SectorID{Miner: abi.ActorID(spid), Number: abi.SectorNumber(id)}, storiface.FTSealed, true, nil)
if err != nil {
return xerrors.Errorf("failed to remove sealed file: %w", err)
}

_, err = a.deps.DB.Exec(ctx, `SELECT unset_task_id($1, $2)`, spid, id)
if err != nil {
return xerrors.Errorf("failed to resume sector: %w", err)
}
return nil
}
28 changes: 20 additions & 8 deletions web/static/pages/sector/sector-info.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ customElements.define('sector-info',class SectorInfo extends LitElement {
await RPCCall('SectorResume', [this.data.SpID, this.data.SectorNumber]);
window.location.reload();
}
async restartSector() {
await RPCCall('SectorRestart', [this.data.SpID, this.data.SectorNumber]);
window.location.reload();
}

render() {
if (!this.data) {
Expand All @@ -29,14 +33,22 @@ customElements.define('sector-info',class SectorInfo extends LitElement {
return html`
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="/ux/main.css" onload="document.body.style.visibility = 'initial'">
<h2>Sector ${this.data.SectorNumber}</h2>
<div>
<details>
<summary class="btn btn-warning">Remove ${!this.data.PipelinePoRep?.Failed ? '(THIS SECTOR IS NOT FAILED!)' : ''}</summary>
<button class="btn btn-danger" @click="${() => this.removeSector()}">Confirm Remove</button>
</details>
${this.data.Resumable ? html`<button class="btn btn-primary" @click="${() => this.resumeSector()}">Resume</button>` : ''}
<div class="row" style="margin-bottom: 20px;">
<h2 style="text-align: center; margin-top: 20px;">Sector ${this.data.SectorNumber}</h2>
<div class="col-md-auto">
<details>
<summary class="btn btn-warning">Remove ${!this.data.PipelinePoRep?.Failed ? '(THIS SECTOR IS NOT FAILED!)' : ''}</summary>
<button class="btn btn-danger" @click="${() => this.removeSector()}">Confirm Remove</button>
</details>
</div>
<div class="col-md-auto">
${this.data.Restart ? html`<details>
<summary class="btn btn-warning">Restart (THIS WILL RESTART SECTOR FROM SDR!)</summary>
<button class="btn btn-danger" @click="${() => this.restartSector()}"> Confirm Restart</button></details>` : ''}
</div>
<div class="col-md-auto">
${this.data.Resumable ? html`<button class="btn btn-primary" @click="${() => this.resumeSector()}">Resume</button>` : ''}
</div>
</div>
<div>
<h3>PoRep Pipeline</h3>
Expand Down

0 comments on commit 8257357

Please sign in to comment.