fn: minor error code simplification (#1341)

There is no need to propagate CapacityFull to waitHot(). Instead
waitHot() can receive 503 which is easier to follow (and less
error prone) in handleCallEnd().
This commit is contained in:
Tolga Ceylan
2018-12-05 23:59:47 -08:00
committed by GitHub
parent 7aa93b12bb
commit 1f17edf78a
2 changed files with 7 additions and 7 deletions

View File

@@ -311,19 +311,19 @@ func (a *agent) handleCallEnd(ctx context.Context, call *call, slot Slot, err er
statsStopRun(ctx) statsStopRun(ctx)
if err == nil { if err == nil {
statsComplete(ctx) statsComplete(ctx)
} else if err == context.DeadlineExceeded {
statsTimedout(ctx)
return models.ErrCallTimeout
} }
} else { } else {
statsDequeue(ctx) statsDequeue(ctx)
if err == CapacityFull || err == context.DeadlineExceeded { if err == models.ErrCallTimeoutServerBusy || err == context.DeadlineExceeded {
statsTooBusy(ctx) statsTooBusy(ctx)
return models.ErrCallTimeoutServerBusy return models.ErrCallTimeoutServerBusy
} }
} }
if err == context.DeadlineExceeded { if err == context.Canceled {
statsTimedout(ctx)
return models.ErrCallTimeout
} else if err == context.Canceled {
statsCanceled(ctx) statsCanceled(ctx)
} else if err != nil { } else if err != nil {
statsErrors(ctx) statsErrors(ctx)
@@ -487,7 +487,7 @@ func (a *agent) checkLaunch(ctx context.Context, call *call, caller slotCaller)
notifyChans = a.evictor.PerformEviction(call.slotHashId, needMem, uint64(needCpu)) notifyChans = a.evictor.PerformEviction(call.slotHashId, needMem, uint64(needCpu))
// For Non-blocking mode, if there's nothing to evict, we emit 503. // For Non-blocking mode, if there's nothing to evict, we emit 503.
if len(notifyChans) == 0 && isNB { if len(notifyChans) == 0 && isNB {
tryNotify(caller.notify, tok.Error()) tryNotify(caller.notify, models.ErrCallTimeoutServerBusy)
} }
} }
} else if a.shutWg.AddSession(1) { } else if a.shutWg.AddSession(1) {

2
vendor/modules.txt vendored
View File

@@ -196,8 +196,8 @@ go.opencensus.io
# golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e # golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e
golang.org/x/crypto/ssh/terminal golang.org/x/crypto/ssh/terminal
# golang.org/x/net v0.0.0-20181017193950-04a2e542c03f # golang.org/x/net v0.0.0-20181017193950-04a2e542c03f
golang.org/x/net/context
golang.org/x/net/trace golang.org/x/net/trace
golang.org/x/net/context
golang.org/x/net/internal/timeseries golang.org/x/net/internal/timeseries
golang.org/x/net/http2 golang.org/x/net/http2
golang.org/x/net/http2/hpack golang.org/x/net/http2/hpack