mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-22 16:36:30 +00:00
agent dont report error if terminated gracefully (#3894)
This commit is contained in:
parent
0575f36374
commit
2d607a9ae4
1 changed files with 16 additions and 10 deletions
|
@ -17,6 +17,7 @@ package rpc
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -85,15 +86,13 @@ func (c *client) Next(ctx context.Context, f rpc.Filter) (*rpc.Workflow, error)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove after adding continuous data exchange by something like #536
|
|
||||||
if strings.Contains(err.Error(), "\"too_many_pings\"") {
|
|
||||||
// https://github.com/woodpecker-ci/woodpecker/issues/717#issuecomment-1049365104
|
|
||||||
log.Trace().Err(err).Msg("grpc: to many keepalive pings without sending data")
|
|
||||||
} else {
|
|
||||||
log.Error().Err(err).Msgf("grpc error: done(): code: %v", status.Code(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
switch status.Code(err) {
|
switch status.Code(err) {
|
||||||
|
case codes.Canceled:
|
||||||
|
if ctx.Err() != nil {
|
||||||
|
// expected as context was canceled
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
case
|
case
|
||||||
codes.Aborted,
|
codes.Aborted,
|
||||||
codes.DataLoss,
|
codes.DataLoss,
|
||||||
|
@ -101,14 +100,21 @@ func (c *client) Next(ctx context.Context, f rpc.Filter) (*rpc.Workflow, error)
|
||||||
codes.Internal,
|
codes.Internal,
|
||||||
codes.Unavailable:
|
codes.Unavailable:
|
||||||
// non-fatal errors
|
// non-fatal errors
|
||||||
|
// TODO: remove after adding continuous data exchange by something like #536
|
||||||
|
if strings.Contains(err.Error(), "\"too_many_pings\"") {
|
||||||
|
// https://github.com/woodpecker-ci/woodpecker/issues/717#issuecomment-1049365104
|
||||||
|
log.Trace().Err(err).Msg("grpc: to many keepalive pings without sending data")
|
||||||
|
} else {
|
||||||
|
log.Error().Err(err).Msgf("grpc error: next(): code: %v", status.Code(err))
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return nil, err
|
return nil, fmt.Errorf("grpc error: next(): code: %v: %w", status.Code(err), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(retry.NextBackOff()):
|
case <-time.After(retry.NextBackOff()):
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil, ctx.Err()
|
return nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue