fix everything pointed as per review

This commit is contained in:
LexLuthr 2022-08-02 15:17:30 +05:30
parent c736dedfa6
commit cdc08e566f
6 changed files with 25 additions and 29 deletions

View File

@ -151,7 +151,7 @@ type StorageMiner interface {
SealingSchedDiag(ctx context.Context, doSched bool) (interface{}, error) //perm:admin
SealingAbort(ctx context.Context, call storiface.CallID) error //perm:admin
//SealingSchedRemove removes a request from sealing pipeline
SealingRemoveRequest(ctx context.Context, SchedId uuid.UUID) error //perm:admin
SealingRemoveRequest(ctx context.Context, schedId uuid.UUID) error //perm:admin
// paths.SectorIndex
StorageAttach(context.Context, storiface.StorageInfo, fsutil.FsStat) error //perm:admin

View File

@ -367,8 +367,8 @@ var sealingAbortCmd = &cli.Command{
ArgsUsage: "[callid]",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "requestId",
Usage: "Specifies that the argument is SchedId of the request to be removed from scheduler",
Name: "sched",
Usage: "Specifies that the argument is UUID of the request to be removed from scheduler",
},
},
Action: func(cctx *cli.Context) error {
@ -384,7 +384,7 @@ var sealingAbortCmd = &cli.Command{
ctx := lcli.ReqContext(cctx)
if cctx.Bool("requestId") {
if cctx.Bool("sched") {
err = nodeApi.SealingRemoveRequest(ctx, uuid.Must(uuid.Parse(cctx.Args().First())))
if err != nil {
return xerrors.Errorf("Failed to removed the request with UUID %s: %w", cctx.Args().First(), err)

View File

@ -2342,7 +2342,7 @@ USAGE:
lotus-miner sealing abort [command options] [callid]
OPTIONS:
--requestId Specifies that the argument is SchedId of the request to be removed from scheduler (default: false)
--sched Specifies that the argument is UUID of the request to be removed from scheduler (default: false)
```

View File

@ -462,8 +462,8 @@ func (sm *StorageMinerAPI) SealingAbort(ctx context.Context, call storiface.Call
return sm.StorageMgr.Abort(ctx, call)
}
func (sm *StorageMinerAPI) SealingRemoveRequest(ctx context.Context, SchedId uuid.UUID) error {
return sm.StorageMgr.RemoveSchedRequest(ctx, SchedId)
func (sm *StorageMinerAPI) SealingRemoveRequest(ctx context.Context, schedId uuid.UUID) error {
return sm.StorageMgr.RemoveSchedRequest(ctx, schedId)
}
func (sm *StorageMinerAPI) MarketImportDealData(ctx context.Context, propCid cid.Cid, path string) error {

View File

@ -1168,10 +1168,8 @@ func (m *Manager) SchedDiag(ctx context.Context, doSched bool) (interface{}, err
return i, nil
}
func (m *Manager) RemoveSchedRequest(ctx context.Context, SchedId uuid.UUID) error {
m.workLk.Lock()
defer m.workLk.Unlock()
return m.sched.RemoveRequest(ctx, SchedId)
func (m *Manager) RemoveSchedRequest(ctx context.Context, schedId uuid.UUID) error {
return m.sched.RemoveRequest(ctx, schedId)
}
func (m *Manager) Close(ctx context.Context) error {

View File

@ -143,9 +143,7 @@ type workerResponse struct {
type rmRequest struct {
id uuid.UUID
rmresE chan error
rmresC chan struct{}
Ctx context.Context
res chan error
}
func newScheduler(assigner string) (*Scheduler, error) {
@ -178,7 +176,7 @@ func newScheduler(assigner string) (*Scheduler, error) {
},
info: make(chan func(interface{})),
rmRequest: make(chan *rmRequest, 1),
rmRequest: make(chan *rmRequest),
closing: make(chan struct{}),
closed: make(chan struct{}),
@ -399,29 +397,28 @@ func (sh *Scheduler) Info(ctx context.Context) (interface{}, error) {
func (sh *Scheduler) removeRequest(rmrequest *rmRequest) {
if sh.SchedQueue.Len() < 0 {
rmrequest.rmresE <- xerrors.New("No requests in the scheduler")
rmrequest.res <- xerrors.New("No requests in the scheduler")
return
}
queue := sh.SchedQueue
for i, r := range *queue {
if r.SchedId == rmrequest.id {
queue.Remove(i)
rmrequest.rmresC <- struct{}{}
rmrequest.res <- nil
return
}
}
rmrequest.rmresE <- xerrors.New("No request with provided details found")
rmrequest.res <- xerrors.New("No request with provided details found")
}
func (sh *Scheduler) RemoveRequest(ctx context.Context, schedId uuid.UUID) error {
retE := make(chan error)
retC := make(chan struct{})
ret := make(chan error, 1)
select {
case sh.rmRequest <- &rmRequest{
id: schedId,
rmresE: retE,
rmresC: retC,
Ctx: ctx,
res: ret,
}:
case <-sh.closing:
return xerrors.New("closing")
@ -430,14 +427,15 @@ func (sh *Scheduler) RemoveRequest(ctx context.Context, schedId uuid.UUID) error
}
select {
case resp := <-retE:
case resp := <-ret:
if resp != nil {
return resp
}
return nil
case <-sh.closing:
return xerrors.New("closing")
case <-ctx.Done():
return ctx.Err()
case <-retC:
return nil
}
}