Merge pull request #4804 from filecoin-project/feat/storage-retwait-cleanup
Expand sched-diag; Command to abort sealing calls
This commit is contained in:
@@ -28,6 +28,7 @@ var sealingCmd = &cli.Command{
|
||||
sealingJobsCmd,
|
||||
sealingWorkersCmd,
|
||||
sealingSchedDiagCmd,
|
||||
sealingAbortCmd,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -124,9 +125,13 @@ var sealingWorkersCmd = &cli.Command{
|
||||
|
||||
var sealingJobsCmd = &cli.Command{
|
||||
Name: "jobs",
|
||||
Usage: "list workers",
|
||||
Usage: "list running jobs",
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{Name: "color"},
|
||||
&cli.BoolFlag{
|
||||
Name: "show-ret-done",
|
||||
Usage: "show returned but not consumed calls",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
color.NoColor = !cctx.Bool("color")
|
||||
@@ -191,6 +196,9 @@ var sealingJobsCmd = &cli.Command{
|
||||
case l.RunWait > 0:
|
||||
state = fmt.Sprintf("assigned(%d)", l.RunWait-1)
|
||||
case l.RunWait == storiface.RWRetDone:
|
||||
if !cctx.Bool("show-ret-done") {
|
||||
continue
|
||||
}
|
||||
state = "ret-done"
|
||||
case l.RunWait == storiface.RWReturned:
|
||||
state = "returned"
|
||||
@@ -208,9 +216,9 @@ var sealingJobsCmd = &cli.Command{
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintf(tw, "%s\t%d\t%s\t%s\t%s\t%s\t%s\n",
|
||||
hex.EncodeToString(l.ID.ID[10:]),
|
||||
hex.EncodeToString(l.ID.ID[:4]),
|
||||
l.Sector.Number,
|
||||
hex.EncodeToString(l.wid[5:]),
|
||||
hex.EncodeToString(l.wid[:4]),
|
||||
hostname,
|
||||
l.Task.Short(),
|
||||
state,
|
||||
@@ -253,3 +261,47 @@ var sealingSchedDiagCmd = &cli.Command{
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var sealingAbortCmd = &cli.Command{
|
||||
Name: "abort",
|
||||
Usage: "Abort a running job",
|
||||
ArgsUsage: "[callid]",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
if cctx.Args().Len() != 1 {
|
||||
return xerrors.Errorf("expected 1 argument")
|
||||
}
|
||||
|
||||
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
jobs, err := nodeApi.WorkerJobs(ctx)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("getting worker jobs: %w", err)
|
||||
}
|
||||
|
||||
var job *storiface.WorkerJob
|
||||
outer:
|
||||
for _, workerJobs := range jobs {
|
||||
for _, j := range workerJobs {
|
||||
if strings.HasPrefix(j.ID.ID.String(), cctx.Args().First()) {
|
||||
j := j
|
||||
job = &j
|
||||
break outer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if job == nil {
|
||||
return xerrors.Errorf("job with specified id prefix not found")
|
||||
}
|
||||
|
||||
fmt.Printf("aborting job %s, task %s, sector %d, running on host %s\n", job.ID.String(), job.Task.Short(), job.Sector.Number, job.Hostname)
|
||||
|
||||
return nodeApi.SealingAbort(ctx, job.ID)
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user