From 52651c130e7239ad63c024b85f64abcd8883fff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gurhem?= Date: Mon, 18 Dec 2023 18:18:18 +0100 Subject: [PATCH 1/5] feat: add health checks --- Protos/V1/health_checks_common.proto | 34 +++++++++++++++++++++++++++ Protos/V1/health_checks_service.proto | 18 ++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 Protos/V1/health_checks_common.proto create mode 100644 Protos/V1/health_checks_service.proto diff --git a/Protos/V1/health_checks_common.proto b/Protos/V1/health_checks_common.proto new file mode 100644 index 000000000..50cc7d039 --- /dev/null +++ b/Protos/V1/health_checks_common.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +package armonik.api.grpc.v1.health_checks; + +option csharp_namespace = "Armonik.Api.Grpc.V1.HealthChecks"; + +/** + * Represents the available health status + */ + enum HealthStatusEnum { + HEALTH_STATUS_ENUM_UNSPECIFIED = 0; /** Unspecified */ + HEALTH_STATUS_ENUM_HEALTHY = 1; /** Service is working without issues */ + HEALTH_STATUS_ENUM_DEGRADED = 2; /** Service has issues but still works */ + HEALTH_STATUS_ENUM_UNHEALTHY = 3; /** Service does not work */ +} + +/** +* Request to check if all services are healthy +*/ +message CheckHealthRequest {} + +/** +* Response to check if all services are healthy +*/ +message CheckHealthResponse { + message ServiceHealth { + string name = 1; // Name of the service (e.g. "control_plane", "database", "redis") + string message = 2; + HealthStatusEnum healthy = 3; + } + + repeated ServiceHealth services = 1; +} + diff --git a/Protos/V1/health_checks_service.proto b/Protos/V1/health_checks_service.proto new file mode 100644 index 000000000..6d88a5e77 --- /dev/null +++ b/Protos/V1/health_checks_service.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package armonik.api.grpc.v1.health_checks; + +import "health_checks_common.proto"; + +option csharp_namespace = "Armonik.Api.Grpc.V1.HealthChecks"; + +/** + * The HealthChecksService provides methods to verify the health of the cluster. + */ +service HealthChecksService { + /** + * Checks the health of the cluster. This can be used to verify that the cluster is up and running. + */ + rpc CheckHealth(CheckHealthRequest) returns (CheckHealthResponse) {} + +} From 7ec122f4023370aeda002f9d79bfba8164989d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gurhem?= Date: Mon, 18 Dec 2023 12:03:59 +0100 Subject: [PATCH 2/5] feat: add health checks services in packages --- packages/common/protofiles.sh | 3 ++- packages/cpp/ArmoniK.Api.Client/CMakeLists.txt | 2 ++ packages/csharp/ArmoniK.Api.Client/ArmoniK.Api.Client.csproj | 3 +++ packages/csharp/ArmoniK.Api.Common/ArmoniK.Api.Common.csproj | 4 ++++ packages/csharp/ArmoniK.Api.Core/ArmoniK.Api.Core.csproj | 3 +++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/common/protofiles.sh b/packages/common/protofiles.sh index e1afae1f9..b4a80e8b1 100644 --- a/packages/common/protofiles.sh +++ b/packages/common/protofiles.sh @@ -7,6 +7,7 @@ export README_PATH=$REPOSITORY_PATH/README.md armonik_worker_files=("agent_service.proto" "worker_service.proto") armonik_client_files=("submitter_service.proto" "tasks_service.proto" "sessions_service.proto" \ "results_service.proto" "applications_service.proto" "auth_service.proto" \ + "health_checks_service.proto" \ "events_service.proto" "partitions_service.proto" "versions_service.proto") armonik_common_files=("objects.proto" "task_status.proto" "session_status.proto" \ "result_status.proto" "agent_common.proto" "sessions_common.proto" \ @@ -17,5 +18,5 @@ armonik_common_files=("objects.proto" "task_status.proto" "session_status.proto" "sessions_fields.proto" "sessions_filters.proto" \ "applications_fields.proto" "applications_filters.proto" \ "partitions_fields.proto" "partitions_filters.proto" \ - "results_fields.proto" "results_filters.proto" \ + "results_fields.proto" "results_filters.proto" "health_checks_common.proto" \ "filters_common.proto") diff --git a/packages/cpp/ArmoniK.Api.Client/CMakeLists.txt b/packages/cpp/ArmoniK.Api.Client/CMakeLists.txt index cc602013b..27d3ccc5b 100644 --- a/packages/cpp/ArmoniK.Api.Client/CMakeLists.txt +++ b/packages/cpp/ArmoniK.Api.Client/CMakeLists.txt @@ -4,6 +4,7 @@ set(PROJECT_BUILD_DIR ${BUILD_DIR}/${PROJECT_NAME}) set(PROTO_FILES "submitter_service.proto" + "health_checks_service.proto" "applications_service.proto" "sessions_service.proto" "tasks_service.proto" @@ -17,6 +18,7 @@ set(PROTO_MESSAGES "auth_common.proto" "sessions_common.proto" "submitter_common.proto" + "health_checks_common.proto" "tasks_common.proto" "results_common.proto" "partitions_common.proto" diff --git a/packages/csharp/ArmoniK.Api.Client/ArmoniK.Api.Client.csproj b/packages/csharp/ArmoniK.Api.Client/ArmoniK.Api.Client.csproj index fa6e1a9c0..1237ce0d3 100644 --- a/packages/csharp/ArmoniK.Api.Client/ArmoniK.Api.Client.csproj +++ b/packages/csharp/ArmoniK.Api.Client/ArmoniK.Api.Client.csproj @@ -70,5 +70,8 @@ gRPC\Protos\versions_service.proto + + gRPC\Protos\health_checks_service.proto + diff --git a/packages/csharp/ArmoniK.Api.Common/ArmoniK.Api.Common.csproj b/packages/csharp/ArmoniK.Api.Common/ArmoniK.Api.Common.csproj index 044fc64c7..3cc6b4698 100755 --- a/packages/csharp/ArmoniK.Api.Common/ArmoniK.Api.Common.csproj +++ b/packages/csharp/ArmoniK.Api.Common/ArmoniK.Api.Common.csproj @@ -58,6 +58,10 @@ Message True + + Message + True + Message True diff --git a/packages/csharp/ArmoniK.Api.Core/ArmoniK.Api.Core.csproj b/packages/csharp/ArmoniK.Api.Core/ArmoniK.Api.Core.csproj index 53916d190..f89005982 100644 --- a/packages/csharp/ArmoniK.Api.Core/ArmoniK.Api.Core.csproj +++ b/packages/csharp/ArmoniK.Api.Core/ArmoniK.Api.Core.csproj @@ -67,6 +67,9 @@ gRPC\Protos\versions_service.proto + + gRPC\Protos\health_checks_service.proto + From 8709779a42a0bfb10be58ab3ef9fe1bb66b2a575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gurhem?= Date: Mon, 18 Dec 2023 12:06:40 +0100 Subject: [PATCH 3/5] style: format proto files --- Protos/V1/health_checks_common.proto | 3 +-- Protos/V1/health_checks_service.proto | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Protos/V1/health_checks_common.proto b/Protos/V1/health_checks_common.proto index 50cc7d039..748121c00 100644 --- a/Protos/V1/health_checks_common.proto +++ b/Protos/V1/health_checks_common.proto @@ -7,7 +7,7 @@ option csharp_namespace = "Armonik.Api.Grpc.V1.HealthChecks"; /** * Represents the available health status */ - enum HealthStatusEnum { +enum HealthStatusEnum { HEALTH_STATUS_ENUM_UNSPECIFIED = 0; /** Unspecified */ HEALTH_STATUS_ENUM_HEALTHY = 1; /** Service is working without issues */ HEALTH_STATUS_ENUM_DEGRADED = 2; /** Service has issues but still works */ @@ -31,4 +31,3 @@ message CheckHealthResponse { repeated ServiceHealth services = 1; } - diff --git a/Protos/V1/health_checks_service.proto b/Protos/V1/health_checks_service.proto index 6d88a5e77..613f71f73 100644 --- a/Protos/V1/health_checks_service.proto +++ b/Protos/V1/health_checks_service.proto @@ -14,5 +14,4 @@ service HealthChecksService { * Checks the health of the cluster. This can be used to verify that the cluster is up and running. */ rpc CheckHealth(CheckHealthRequest) returns (CheckHealthResponse) {} - } From 66fff56787f25134fb01a6d583601a86e8e5d45a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gurhem?= Date: Mon, 18 Dec 2023 15:24:10 +0100 Subject: [PATCH 4/5] fix: use proper csharp namespace --- Protos/V1/health_checks_common.proto | 2 +- Protos/V1/health_checks_service.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Protos/V1/health_checks_common.proto b/Protos/V1/health_checks_common.proto index 748121c00..3c6b43a0b 100644 --- a/Protos/V1/health_checks_common.proto +++ b/Protos/V1/health_checks_common.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package armonik.api.grpc.v1.health_checks; -option csharp_namespace = "Armonik.Api.Grpc.V1.HealthChecks"; +option csharp_namespace = "ArmoniK.Api.gRPC.V1.HealthChecks"; /** * Represents the available health status diff --git a/Protos/V1/health_checks_service.proto b/Protos/V1/health_checks_service.proto index 613f71f73..7a6ce69cf 100644 --- a/Protos/V1/health_checks_service.proto +++ b/Protos/V1/health_checks_service.proto @@ -4,7 +4,7 @@ package armonik.api.grpc.v1.health_checks; import "health_checks_common.proto"; -option csharp_namespace = "Armonik.Api.Grpc.V1.HealthChecks"; +option csharp_namespace = "ArmoniK.Api.gRPC.V1.HealthChecks"; /** * The HealthChecksService provides methods to verify the health of the cluster. From f936d95e51db65c885c23961f6f9cb3c7033aa3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gurhem?= Date: Mon, 18 Dec 2023 17:57:37 +0100 Subject: [PATCH 5/5] feat: implement healt check service in mock --- packages/csharp/ArmoniK.Api.Mock/Program.cs | 1 + .../ArmoniK.Api.Mock/Services/HealthChecks.cs | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 packages/csharp/ArmoniK.Api.Mock/Services/HealthChecks.cs diff --git a/packages/csharp/ArmoniK.Api.Mock/Program.cs b/packages/csharp/ArmoniK.Api.Mock/Program.cs index 2aa6effd2..afc5dc583 100644 --- a/packages/csharp/ArmoniK.Api.Mock/Program.cs +++ b/packages/csharp/ArmoniK.Api.Mock/Program.cs @@ -79,6 +79,7 @@ app.MapGrpcService(); app.MapGrpcService(); app.MapGrpcService(); +app.MapGrpcService(); app.MapGrpcService(); app.MapGrpcService(); app.MapGrpcService(); diff --git a/packages/csharp/ArmoniK.Api.Mock/Services/HealthChecks.cs b/packages/csharp/ArmoniK.Api.Mock/Services/HealthChecks.cs new file mode 100644 index 000000000..109711160 --- /dev/null +++ b/packages/csharp/ArmoniK.Api.Mock/Services/HealthChecks.cs @@ -0,0 +1,43 @@ +// This file is part of the ArmoniK project +// +// Copyright (C) ANEO, 2021-2023.All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Threading.Tasks; + +using ArmoniK.Api.gRPC.V1.HealthChecks; + +using Grpc.Core; + +namespace ArmoniK.Api.Mock.Services; + +[Counting] +public class HealthChecks : HealthChecksService.HealthChecksServiceBase +{ + [Count] + public override Task CheckHealth(CheckHealthRequest request, + ServerCallContext context) + => Task.FromResult(new CheckHealthResponse + { + Services = + { + new CheckHealthResponse.Types.ServiceHealth + { + Healthy = HealthStatusEnum.Healthy, + Message = "Mock is healthy", + Name = "mock", + }, + }, + }); +}