Skip to content

Commit c2096a3

Browse files
committed
Minor
1 parent 7657445 commit c2096a3

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

internal/workflow/workflow.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
"github.com/serverledge-faas/serverledge/internal/node"
89
"io"
910
"net/http"
1011
"sort"
@@ -519,7 +520,11 @@ func (wflow *Workflow) Invoke(r *Request) error {
519520
}
520521
output, err := wflow.ExecuteTask(r, taskToExecute, input, progress)
521522
if err != nil {
522-
return fmt.Errorf("failed wflow execution: %v", err)
523+
if errors.Is(err, node.OutOfResourcesErr) {
524+
return err
525+
} else {
526+
return fmt.Errorf("failed wflow execution: %v", err)
527+
}
523528
}
524529

525530
dataMap[taskToExecute] = output
@@ -585,7 +590,11 @@ func offload(r *Request, policyDecision *OffloadingDecision) error {
585590
url := fmt.Sprintf("%s/workflow/resume/%s", policyDecision.RemoteHost, r.W.Name)
586591
resp, err := utils.PostJson(url, invocationBody)
587592
if err != nil {
588-
return fmt.Errorf("HTTP request for offloading failed: %v", err)
593+
if resp != nil && resp.StatusCode == http.StatusTooManyRequests {
594+
return node.OutOfResourcesErr
595+
} else {
596+
return fmt.Errorf("HTTP request for offloading failed: %v", err)
597+
}
589598
}
590599

591600
if resp.StatusCode != http.StatusOK {

0 commit comments

Comments
 (0)