From 279549be94c988e96a78007176ee30ec94a9b15b Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Wed, 4 Dec 2024 16:48:57 +0300 Subject: [PATCH] [#1539] node: Support healthcheck server for gRPC services Signed-off-by: Airat Arifullin --- cmd/frostfs-node/grpc_health.go | 20 ++++++++++++++++++++ cmd/frostfs-node/main.go | 2 ++ go.mod | 2 ++ go.sum | Bin 41910 -> 41906 bytes 4 files changed, 24 insertions(+) create mode 100644 cmd/frostfs-node/grpc_health.go diff --git a/cmd/frostfs-node/grpc_health.go b/cmd/frostfs-node/grpc_health.go new file mode 100644 index 000000000..a2b50535c --- /dev/null +++ b/cmd/frostfs-node/grpc_health.go @@ -0,0 +1,20 @@ +package main + +import ( + "net" + + "google.golang.org/grpc" + "google.golang.org/grpc/health" + healthV1 "google.golang.org/grpc/health/grpc_health_v1" +) + +func initGRPCHealth(c *cfg) { + healthServer := health.NewServer() + c.cfgGRPC.performAndSave(func(_ string, _ net.Listener, srv *grpc.Server) { + healthV1.RegisterHealthServer(srv, healthServer) + healthServer.SetServingStatus("", healthV1.HealthCheckResponse_SERVING) + }) + c.onShutdown(func() { + healthServer.SetServingStatus("", healthV1.HealthCheckResponse_NOT_SERVING) + }) +} diff --git a/cmd/frostfs-node/main.go b/cmd/frostfs-node/main.go index f8854ab3c..28f09c5e2 100644 --- a/cmd/frostfs-node/main.go +++ b/cmd/frostfs-node/main.go @@ -117,6 +117,8 @@ func initApp(ctx context.Context, c *cfg) { initAndLog(ctx, c, "control", func(c *cfg) { initControlService(ctx, c) }) initAndLog(ctx, c, "morph notifications", func(c *cfg) { listenMorphNotifications(ctx, c) }) + + initAndLog(ctx, c, "grpc_health", initGRPCHealth) } func runAndLog(ctx context.Context, c *cfg, name string, logSuccess bool, starter func(context.Context, *cfg)) { diff --git a/go.mod b/go.mod index c538a3178..054f7da1c 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module git.frostfs.info/TrueCloudLab/frostfs-node go 1.22 +replace git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20241107121119-cb813e27a823 => git.frostfs.info/aarifullin/frostfs-sdk-go v0.0.0-20241204121743-ab885d24496a + require ( code.gitea.io/sdk/gitea v0.17.1 git.frostfs.info/TrueCloudLab/frostfs-contract v0.21.0-rc.4 diff --git a/go.sum b/go.sum index 064f3274e4cc79d8789b54ce3fdc6455024c046d..3b674d503cae237d84962e4fb33abaebe823f601 100644 GIT binary patch delta 154 zcmdmXoN3c>rVTS$HZNdRVVf+*$j6nKSd^Jonv;{6H+cq&jH{7>iJ_69xrwoEVv>c0 zX^N4FiKSVhLWZH0n^|U}shf*WRAF94MX0-JRYb0zQlc{4+dVp6@N>-YuXO62; axl{RMK}KOTgT=5LJlTuYdh-$PPtyUtP%tI*hf3Ez%xfMHWRvlI@t>%56Q_oLzeJOcoWk%?G$YO$Pu;TsCI_