Skip to content

Commit

Permalink
Do not report fatal error if err is server closed (#9559)
Browse files Browse the repository at this point in the history
Because we use the cmux, closing the listener causes the cmux to close which will cause the grpc/http servers to also close with a `cmux.ErrServerClosed` error.

Signed-off-by: Bogdan Drutu <[email protected]>

Co-authored-by: Alex Boten <[email protected]>
  • Loading branch information
bogdandrutu and Alex Boten authored May 3, 2022
1 parent 28f2550 commit aaae303
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- `k8sclusterreceiver`: Fix the receiver to work with 1.19 and 1.20 k8s API versions (#9523)
- `azuremonitorexporter`: Fix log exporter bug related to incorrectly mapping SpanId (#9579)
- `mysqlreceiver`: Fix attribute values mismatch with its definition (#9688)
- `opencensusreceiver`: Do not report fatal error if err is server closed (#9559).

## v0.50.0

Expand Down
14 changes: 8 additions & 6 deletions receiver/opencensusreceiver/opencensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,20 @@ func (ocr *ocReceiver) startServer(host component.Host) error {

httpL := m.Match(cmux.Any())
go func() {
if errGrpc := ocr.serverGRPC.Serve(grpcL); !errors.Is(errGrpc, grpc.ErrServerStopped) && errGrpc != nil {
host.ReportFatalError(errGrpc)
// Check for cmux.ErrServerClosed, because during the shutdown this is not properly close before closing the cmux,
// see TODO in Shutdown.
if err := ocr.serverGRPC.Serve(grpcL); !errors.Is(err, grpc.ErrServerStopped) && !errors.Is(err, cmux.ErrServerClosed) && err != nil {
host.ReportFatalError(err)
}
}()
go func() {
if errHTTP := ocr.httpServer().Serve(httpL); !errors.Is(errHTTP, http.ErrServerClosed) && errHTTP != nil {
host.ReportFatalError(errHTTP)
if err := ocr.httpServer().Serve(httpL); !errors.Is(err, http.ErrServerClosed) && err != nil {
host.ReportFatalError(err)
}
}()
go func() {
if errServe := m.Serve(); errServe != nil && errServe != cmux.ErrServerClosed {
host.ReportFatalError(errServe)
if err := m.Serve(); !errors.Is(err, cmux.ErrServerClosed) && err != nil {
host.ReportFatalError(err)
}
}()
return nil
Expand Down

0 comments on commit aaae303

Please sign in to comment.