agent dont report error if terminated gracefully (#3894)

This commit is contained in:
6543 2024-07-12 18:24:55 -07:00 committed by GitHub
parent 0575f36374
commit 2d607a9ae4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
} }
} }