mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Add APIErrorWrapper so that underlying errors can be logged (#1246)
This commit is contained in:
@@ -34,12 +34,10 @@ func (p *chPlacer) PlaceCall(rp RunnerPool, ctx context.Context, call RunnerCall
|
||||
key := call.Model().FnID
|
||||
sum64 := siphash.Hash(0, 0x4c617279426f6174, []byte(key))
|
||||
|
||||
var runnerPoolErr error
|
||||
for {
|
||||
runners, err := rp.Runners(call)
|
||||
if err != nil {
|
||||
state.HandleFindRunnersFailure(err)
|
||||
return err
|
||||
}
|
||||
var runners []Runner
|
||||
runners, runnerPoolErr = rp.Runners(call)
|
||||
|
||||
i := int(jumpConsistentHash(sum64, int32(len(runners))))
|
||||
for j := 0; j < len(runners) && !state.IsDone(); j++ {
|
||||
@@ -59,6 +57,14 @@ func (p *chPlacer) PlaceCall(rp RunnerPool, ctx context.Context, call RunnerCall
|
||||
}
|
||||
}
|
||||
|
||||
if runnerPoolErr != nil {
|
||||
// If we haven't been able to place the function and we got an error
|
||||
// from the runner pool, return that error (since we don't have
|
||||
// enough runners to handle the current load and the runner pool is
|
||||
// having trouble).
|
||||
state.HandleFindRunnersFailure(runnerPoolErr)
|
||||
return runnerPoolErr
|
||||
}
|
||||
return models.ErrCallTimeoutServerBusy
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,10 @@ func (sp *naivePlacer) PlaceCall(rp RunnerPool, ctx context.Context, call Runner
|
||||
state := NewPlacerTracker(ctx, &sp.cfg)
|
||||
defer state.HandleDone()
|
||||
|
||||
var runnerPoolErr error
|
||||
for {
|
||||
runners, err := rp.Runners(call)
|
||||
if err != nil {
|
||||
state.HandleFindRunnersFailure(err)
|
||||
return err
|
||||
}
|
||||
var runners []Runner
|
||||
runners, runnerPoolErr = rp.Runners(call)
|
||||
|
||||
for j := 0; j < len(runners) && !state.IsDone(); j++ {
|
||||
|
||||
@@ -51,5 +49,13 @@ func (sp *naivePlacer) PlaceCall(rp RunnerPool, ctx context.Context, call Runner
|
||||
}
|
||||
}
|
||||
|
||||
if runnerPoolErr != nil {
|
||||
// If we haven't been able to place the function and we got an error
|
||||
// from the runner pool, return that error (since we don't have
|
||||
// enough runners to handle the current load and the runner pool is
|
||||
// having trouble).
|
||||
state.HandleFindRunnersFailure(runnerPoolErr)
|
||||
return runnerPoolErr
|
||||
}
|
||||
return models.ErrCallTimeoutServerBusy
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user