fix: harmony: Try other tasks when storage claim fails

This commit is contained in:
Łukasz Magiera 2024-04-04 12:12:35 +02:00 committed by Łukasz Magiera
parent 385fb7a054
commit 485050ee7c

View File

@ -85,6 +85,7 @@ top:
} }
// 3. What does the impl say? // 3. What does the impl say?
canAcceptAgain:
tID, err := h.CanAccept(ids, h.TaskEngine) tID, err := h.CanAccept(ids, h.TaskEngine)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
@ -100,6 +101,18 @@ top:
if h.TaskTypeDetails.Cost.Storage != nil { if h.TaskTypeDetails.Cost.Storage != nil {
if err = h.TaskTypeDetails.Cost.Storage.Claim(int(*tID)); err != nil { 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) log.Infow("did not accept task", "task_id", strconv.Itoa(int(*tID)), "reason", "storage claim failed", "name", h.Name, "error", err)
if len(ids) > 1 {
var tryAgain = make([]TaskID, 0, len(ids)-1)
for _, id := range ids {
if id != *tID {
tryAgain = append(tryAgain, id)
}
}
ids = tryAgain
goto canAcceptAgain
}
return false return false
} }
releaseStorage = func() { releaseStorage = func() {