diff --git a/cmd/lotus-provider/deps/deps.go b/cmd/lotus-provider/deps/deps.go index e5fb45bc1cc..cad7602bb1d 100644 --- a/cmd/lotus-provider/deps/deps.go +++ b/cmd/lotus-provider/deps/deps.go @@ -254,8 +254,6 @@ Get it with: jq .PrivateKey ~/.lotus-miner/keystore/MF2XI2BNNJ3XILLQOJUXMYLUMU`, } } - fmt.Println("last line of populate") - return nil } diff --git a/lib/harmony/harmonytask/harmonytask.go b/lib/harmony/harmonytask/harmonytask.go index 1adc1df285a..01f2febba62 100644 --- a/lib/harmony/harmonytask/harmonytask.go +++ b/lib/harmony/harmonytask/harmonytask.go @@ -314,13 +314,3 @@ func (e *TaskEngine) ResourcesAvailable() resources.Resources { } return tmp } - -// This helps .Do() determine where its storage allocation is. -func (e *TaskEngine) GetWorkingLocation(taskID TaskID) string { - for _, t := range e.handlers { - if v, ok := t.LocationMap.Load(taskID); ok { - return v.(string) - } - } - return "" -} diff --git a/lib/harmony/harmonytask/task_type_handler.go b/lib/harmony/harmonytask/task_type_handler.go index ba770c0da68..2b252194942 100644 --- a/lib/harmony/harmonytask/task_type_handler.go +++ b/lib/harmony/harmonytask/task_type_handler.go @@ -6,7 +6,6 @@ import ( "fmt" "runtime" "strconv" - "sync" "sync/atomic" "time" @@ -20,9 +19,8 @@ var log = logging.Logger("harmonytask") type taskTypeHandler struct { TaskInterface TaskTypeDetails - TaskEngine *TaskEngine - Count atomic.Int32 - LocationMap sync.Map + TaskEngine *TaskEngine + Count atomic.Int32 } func (h *taskTypeHandler) AddTask(extra func(TaskID, *harmonydb.Tx) (bool, error)) { @@ -97,21 +95,16 @@ top: return false } - var location string releaseStorage := func() { } if h.TaskTypeDetails.Cost.Storage != nil { - if c := h.TaskTypeDetails.Cost.Storage.Claim; c != nil { - if err = c(int(*tID)); err != nil { - log.Infow("did not accept task", "task_id", strconv.Itoa(int(*tID)), "reason", "storage claim failed", "name", h.Name, "error", err) - return false - } - h.LocationMap.Store(*tID, location) - releaseStorage = func() { - if err := h.TaskTypeDetails.Cost.Storage.MarkComplete(); err != nil { - log.Errorw("Could not release storage", "error", err) - } - h.LocationMap.Delete(*tID) + if err = h.TaskTypeDetails.Cost.Storage.Claim(int(*tID)); err != nil { + log.Infow("did not accept task", "task_id", strconv.Itoa(int(*tID)), "reason", "storage claim failed", "name", h.Name, "error", err) + return false + } + releaseStorage = func() { + if err := h.TaskTypeDetails.Cost.Storage.MarkComplete(int(*tID)); err != nil { + log.Errorw("Could not release storage", "error", err) } } } @@ -128,6 +121,8 @@ top: } if ct == 0 { log.Infow("did not accept task", "task_id", strconv.Itoa(int(*tID)), "reason", "already Taken", "name", h.Name) + releaseStorage() + var tryAgain = make([]TaskID, 0, len(ids)-1) for _, id := range ids { if id != *tID { @@ -273,7 +268,7 @@ func (h *taskTypeHandler) AssertMachineHasCapacity() error { } if h.TaskTypeDetails.Cost.Storage != nil { - if has := h.TaskTypeDetails.Cost.Storage.HasCapacity; has != nil && !has() { + if !h.TaskTypeDetails.Cost.Storage.HasCapacity() { return errors.New("Did not accept " + h.Name + " task: out of available Storage") } } diff --git a/lib/harmony/resources/resources.go b/lib/harmony/resources/resources.go index 2f5d09d4350..4f67a26aff7 100644 --- a/lib/harmony/resources/resources.go +++ b/lib/harmony/resources/resources.go @@ -28,7 +28,6 @@ type Resources struct { } // Optional Storage management. -// See storagemgr/storagemgt.go for more details. type Storage interface { HasCapacity() bool @@ -37,7 +36,7 @@ type Storage interface { // This allows some other system to consider the task done. // It's up to the caller to remove the data, if that applies. - MarkComplete() error + MarkComplete(taskID int) error } type Reg struct { Resources