Fix misleading log msg on shutdown (#13063)

* Fix misleading log msg on shutdown

gRPCServer.GracefulStop blocks until it has been shutdown. Logging
"Initiated graceful stop" after it has been completed is misleading.
Names are added to the message to discern services. Also, a minimum test
is added mainly to verify the change made with this commit.

* Add changelog fragment file

* Capitalize log messages

* Update endtoend test for fixed log messages

---------

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
hyunchel
2025-09-17 18:14:40 -04:00
committed by GitHub
parent c941e47b7e
commit 5266d34a22
5 changed files with 9 additions and 6 deletions

View File

@@ -145,7 +145,7 @@ func NewService(ctx context.Context, cfg *Config) *Service {
log.WithError(err).Errorf("Could not listen to port in Start() %s", address)
}
s.listener = lis
log.WithField("address", address).Info("gRPC server listening on port")
log.WithField("address", address).Info("Beacon chain gRPC server listening")
opts := []grpc.ServerOption{
grpc.StatsHandler(otelgrpc.NewServerHandler()),
@@ -351,7 +351,7 @@ func (s *Service) Stop() error {
s.cancel()
if s.listener != nil {
s.grpcServer.GracefulStop()
log.Debug("Initiated graceful stop of gRPC server")
log.Debug("Completed graceful stop of beacon-chain gRPC server")
}
return nil
}

View File

@@ -42,8 +42,9 @@ func TestLifecycle_OK(t *testing.T) {
rpcService.Start()
require.LogsContain(t, hook, "listening on port")
require.LogsContain(t, hook, "Beacon chain gRPC server listening")
assert.NoError(t, rpcService.Stop())
require.LogsContain(t, hook, "Completed graceful stop of beacon-chain gRPC server")
}
func TestStatus_CredentialError(t *testing.T) {
@@ -84,7 +85,7 @@ func TestRPC_InsecureEndpoint(t *testing.T) {
rpcService.Start()
require.LogsContain(t, hook, "listening on port")
require.LogsContain(t, hook, "Beacon chain gRPC server listening")
require.LogsContain(t, hook, "You are using an insecure gRPC server")
assert.NoError(t, rpcService.Stop())
}

View File

@@ -0,0 +1,3 @@
### Changed
- Clarified misleading log messages in beacon-chain/rpc/service gRPC module.

View File

@@ -308,7 +308,7 @@ func (node *BeaconNode) Start(ctx context.Context) error {
return fmt.Errorf("failed to start beacon node: %w", err)
}
if err = helpers.WaitForTextInFile(stdOutFile, "gRPC server listening on port"); err != nil {
if err = helpers.WaitForTextInFile(stdOutFile, "Beacon chain gRPC server listening"); err != nil {
return fmt.Errorf("could not find multiaddr for node %d, this means the node had issues starting: %w", index, err)
}

View File

@@ -58,5 +58,4 @@ func TestServer_InitializeRoutes(t *testing.T) {
}
}
}
}