Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: restart button for sectors #266

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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