Skip to content

Commit

Permalink
agent dont report error if terminated gracefully (#3894)
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 authored Jul 13, 2024
1 parent 0575f36 commit 2d607a9
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions agent/rpc/client_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package rpc
import (
"context"
"encoding/json"
"fmt"
"strings"
"time"

Expand Down Expand Up @@ -85,30 +86,35 @@ func (c *client) Next(ctx context.Context, f rpc.Filter) (*rpc.Workflow, error)
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) {
case codes.Canceled:
if ctx.Err() != nil {
// expected as context was canceled
return nil, nil
}
return nil, err
case
codes.Aborted,
codes.DataLoss,
codes.DeadlineExceeded,
codes.Internal,
codes.Unavailable:
// 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:
return nil, err
return nil, fmt.Errorf("grpc error: next(): code: %v: %w", status.Code(err), err)
}

select {
case <-time.After(retry.NextBackOff()):
case <-ctx.Done():
return nil, ctx.Err()
return nil, nil
}
}

Expand Down

0 comments on commit 2d607a9

Please sign in to comment.