From 9a5f9d6f0eb6cb0f4c196abb3c1e25f1a6bcc5c2 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Sat, 30 Jul 2022 07:53:35 +0300 Subject: [PATCH] [#1643] innerring: Exit if we cannot bind to the control endpoint Return listen errors in a synchronous fashion. Another solution would be to use buffered channel, but this is not scalable: for each new similar runner we would need to extend the buffer. Signed-off-by: Evgenii Stratonikov --- CHANGELOG.md | 1 + pkg/innerring/innerring.go | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab69b133b..2b8c97e7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Changelog for NeoFS Node ### Fixed - Losing request context in eACL response checks (#1595) +- `neofs-ir` no longer hangs if it cannot bind to the control endpoint (#1643) - Do not require `lifetime` flag in `session create` CLI command (#1655) ### Removed diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index d843e3557..0c6f16921 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -121,7 +121,7 @@ type ( // Set of component runners which // should report start errors // to the application. - runners []func(chan<- error) + runners []func(chan<- error) error subnetHandler } @@ -256,7 +256,9 @@ func (s *Server) Start(ctx context.Context, intError chan<- error) (err error) { } for _, runner := range s.runners { - runner(intError) + if err := runner(intError); err != nil { + return err + } } go s.morphListener.ListenWithError(ctx, morphErr) // listen for neo:morph events @@ -891,16 +893,16 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- grpcControlSrv := grpc.NewServer() control.RegisterControlServiceServer(grpcControlSrv, controlSvc) - server.runners = append(server.runners, func(ch chan<- error) { + server.runners = append(server.runners, func(ch chan<- error) error { lis, err := net.Listen("tcp", controlSvcEndpoint) if err != nil { - ch <- err - return + return err } go func() { ch <- grpcControlSrv.Serve(lis) }() + return nil }) server.registerNoErrCloser(grpcControlSrv.GracefulStop)