From 627b3027456fc87605d9a82490088cd2c767dbe4 Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Mon, 2 Oct 2023 10:38:11 +0300 Subject: [PATCH] [#709] node: Put in log info about listening endpoints Signed-off-by: Anton Nikiforov --- cmd/frostfs-node/control.go | 7 ++++++- cmd/frostfs-node/grpc.go | 3 ++- cmd/frostfs-node/httpcomponent.go | 5 +++++ cmd/frostfs-node/notificator.go | 2 ++ internal/logs/logs.go | 3 ++- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/frostfs-node/control.go b/cmd/frostfs-node/control.go index 3ed6bc54a..787fe3351 100644 --- a/cmd/frostfs-node/control.go +++ b/cmd/frostfs-node/control.go @@ -14,6 +14,8 @@ import ( "google.golang.org/grpc" ) +const serviceNameControl = "control" + type treeSynchronizer struct { treeSvc *tree.Service } @@ -66,7 +68,10 @@ func initControlService(c *cfg) { control.RegisterControlServiceServer(c.cfgControlService.server, ctlSvc) c.workers = append(c.workers, newWorkerFromFunc(func(ctx context.Context) { - runAndLog(ctx, c, "control", false, func(context.Context, *cfg) { + runAndLog(ctx, c, serviceNameControl, false, func(context.Context, *cfg) { + c.log.Info(logs.FrostFSNodeStartListeningEndpoint, + zap.String("service", serviceNameControl), + zap.String("endpoint", endpoint)) fatalOnErr(c.cfgControlService.server.Serve(lis)) }) })) diff --git a/cmd/frostfs-node/grpc.go b/cmd/frostfs-node/grpc.go index 42059ec09..74df7a18f 100644 --- a/cmd/frostfs-node/grpc.go +++ b/cmd/frostfs-node/grpc.go @@ -110,7 +110,8 @@ func serveGRPC(c *cfg) { c.wg.Done() }() - c.log.Info(logs.FrostFSNodeStartListeningGRPCEndpoint, + c.log.Info(logs.FrostFSNodeStartListeningEndpoint, + zap.String("service", "gRPC"), zap.Stringer("endpoint", lis.Addr()), ) diff --git a/cmd/frostfs-node/httpcomponent.go b/cmd/frostfs-node/httpcomponent.go index db9239384..6e8fa8f2c 100644 --- a/cmd/frostfs-node/httpcomponent.go +++ b/cmd/frostfs-node/httpcomponent.go @@ -6,7 +6,9 @@ import ( "net/http" "time" + "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" httputil "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/http" + "go.uber.org/zap" ) type httpComponent struct { @@ -42,6 +44,9 @@ func (cmp *httpComponent) init(c *cfg) { cmp.name, func(ctx context.Context) { runAndLog(ctx, c, cmp.name, false, func(context.Context, *cfg) { + c.log.Info(logs.FrostFSNodeStartListeningEndpoint, + zap.String("service", cmp.name), + zap.String("endpoint", cmp.address)) fatalOnErr(srv.Serve()) }) }, diff --git a/cmd/frostfs-node/notificator.go b/cmd/frostfs-node/notificator.go index 3fa486955..8e581505f 100644 --- a/cmd/frostfs-node/notificator.go +++ b/cmd/frostfs-node/notificator.go @@ -167,5 +167,7 @@ func connectNats(ctx context.Context, c *cfg) { err := c.cfgNotifications.nw.w.Connect(ctx, endpoint) if err != nil { panic(fmt.Sprintf("could not connect to a nats endpoint %s: %v", endpoint, err)) + } else { + c.log.Info(logs.NatsConnectedToEndpoint, zap.String("endpoint", endpoint)) } } diff --git a/internal/logs/logs.go b/internal/logs/logs.go index c18d191f8..56312f83f 100644 --- a/internal/logs/logs.go +++ b/internal/logs/logs.go @@ -123,6 +123,7 @@ const ( NatsNatsConnectionWasLost = "nats: connection was lost" NatsNatsReconnectedToTheServer = "nats: reconnected to the server" NatsNatsClosingConnectionAsTheContextIsDone = "nats: closing connection as the context is done" + NatsConnectedToEndpoint = "nats: successfully connected to endpoint" ControllerStartingToAnnounceTheValuesOfTheMetrics = "starting to announce the values of the metrics" ControllerCouldNotInitializeIteratorOverLocallyCollectedMetrics = "could not initialize iterator over locally collected metrics" ControllerCouldNotInitializeAnnouncementAccumulator = "could not initialize announcement accumulator" @@ -413,10 +414,10 @@ const ( FrostFSIRCouldntCreateRPCClientForEndpoint = "could not create RPC client for endpoint" FrostFSIRCreatedRPCClientForEndpoint = "created RPC client for endpoint" FrostFSIRReloadExtraWallets = "reload extra wallets" + FrostFSNodeStartListeningEndpoint = "start listening endpoint" FrostFSNodeCouldNotReadCertificateFromFile = "could not read certificate from file" FrostFSNodeCantListenGRPCEndpoint = "can't listen gRPC endpoint" FrostFSNodeStopListeningGRPCEndpoint = "stop listening gRPC endpoint" - FrostFSNodeStartListeningGRPCEndpoint = "start listening gRPC endpoint" FrostFSNodeStoppingGRPCServer = "stopping gRPC server..." FrostFSNodeGRPCCannotShutdownGracefullyForcingStop = "gRPC cannot shutdown gracefully, forcing stop" FrostFSNodeGRPCServerStoppedSuccessfully = "gRPC server stopped successfully"