-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drive health #269
Drive health #269
Conversation
* Update to dotnet 8 (and needed updates) * Add grpc endpoint for health checks with rich data * Add brief public health endpoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 35 of 35 files at r1, all commit messages.
Reviewable status: all files reviewed, 14 unresolved discussions (waiting on @johnml1135)
samples/EchoTranslationEngine/EchoTranslationEngine.csproj
line 16 at r1 (raw file):
<ItemGroup> <ProjectReference Include="..\..\src\Serval.Grpc\Serval.Grpc.csproj" /> <ProjectReference Include="..\..\src\Serval.Shared\Serval.Shared.csproj" />
I don't think this is needed.
samples/EchoTranslationEngine/TranslationEngineServiceV1.cs
line 3 at r1 (raw file):
namespace EchoTranslationEngine; public class TranslationEngineServiceV1(BackgroundTaskQueue taskQueue, HealthCheckService healthCheckService) : TranslationEngineApi.TranslationEngineApiBase
You should update csharpier so that this get formatted correctly.
src/Serval.ApiServer/Startup.cs
line 45 at r1 (raw file):
services.AddHealthChecks().AddIdentityServer(new Uri(authority), name: "Auth0"); string DataFilesDir = Configuration!.GetSection(DataFileOptions.Key)!.GetValue<string>("FilesDirectory")!;
I don't think that the null-forgiving operators are needed here.
src/Serval.ApiServer/Startup.cs
line 47 at r1 (raw file):
string DataFilesDir = Configuration!.GetSection(DataFileOptions.Key)!.GetValue<string>("FilesDirectory")!; // find drive letter for DataFilesDir string driveLetter = Path.GetPathRoot(DataFilesDir)![..1];
Please avoid using the null-forgiving operator.
src/Serval.ApiServer/Startup.cs
line 216 at r1 (raw file):
x.MapHangfireDashboard(); x.MapHealthChecks("/health", new HealthCheckOptions { ResponseWriter = WriteHealthCheckResponse.Generate }); ;
There is an extra semicolon here.
src/Serval.ApiServer/Controllers/StatusController.cs
line 50 at r1 (raw file):
/// <remarks>Provides an indication about the health of the API</remarks> /// <response code="200">The API health status</response> [HttpGet("health-public")]
I would call this something else. Maybe ping
.
src/Serval.Grpc/Protos/serval/translation/v1/engine.proto
line 108 at r1 (raw file):
message HealthCheckResponse { HealthCheckStatus Status = 1;
This should be snake case.
src/Serval.Grpc/Protos/serval/translation/v1/engine.proto
line 109 at r1 (raw file):
message HealthCheckResponse { HealthCheckStatus Status = 1; string Duration = 2;
Do we really need this?
src/Serval.Grpc/Protos/serval/translation/v1/engine.proto
line 110 at r1 (raw file):
HealthCheckStatus Status = 1; string Duration = 2; map<string, string> Data = 3;
What is this used for?
src/Serval.Grpc/Protos/serval/translation/v1/engine.proto
line 111 at r1 (raw file):
string Duration = 2; map<string, string> Data = 3; optional string Exception = 4;
I would rename this to error
or more generally description
. Remember this is defining an API for engines. An engine could be implemented on any tech stack. We don't need to, nor should we match the C# health check models exactly. All we really need is status
and description
.
src/Serval.Grpc/Protos/serval/translation/v1/engine.proto
line 163 at r1 (raw file):
enum HealthCheckStatus { Unhealthy = 0;
These should be all uppercase in order to be consistent with the other enums.
src/Serval.Shared/Configuration/IServalBuilderExtensions.cs
line 46 at r1 (raw file):
) { builder.Services.AddMongoDataAccess(builder.Configuration!.GetConnectionString("Mongo")!, "Serval", configure);
Please avoid using the null-forgiving operator. Throw an exception if necessary.
src/Serval.Shared/Controllers/ServiceUnavailableExceptionFilter.cs
line 21 at r1 (raw file):
_logger.Log( LogLevel.Error, "A user tried to access an unavailable service. Exception: \n{Exception}",
We already pass the exception to the Log
method. This might be redundant.
src/Serval.Shared/Utils/WriteHealthCheckResponse.cs
line 5 at r1 (raw file):
public class WriteHealthCheckResponse { public static Task Generate(HttpContext context, HealthReport healthReport)
This is only used in Serval.ApiServer
, so you can move it there.
src/Serval.Shared/Contracts/HealthReportDto.cs
line 0 at r1 (raw file):
Why have these DTOs been moved?
Previously, ddaspit (Damien Daspit) wrote…
Correct. Removed. |
Previously, ddaspit (Damien Daspit) wrote…
It's the new net8.0 primary constructor. |
Previously, ddaspit (Damien Daspit) wrote…
net8 was complaining about it - is there a better way? Should I use a ? or a if statement? If it is null, I would want to crash out of the code. |
Previously, johnml1135 (John Lambert) wrote…
I see what I was doing - I was confusing the null forgiving operator in CSharp (!) with the not-null assertion operator in Kotlin (!!). I will change them to the |
Previously, ddaspit (Damien Daspit) wrote…
Done |
Previously, ddaspit (Damien Daspit) wrote…
fixed. |
Previously, ddaspit (Damien Daspit) wrote…
ping is ok. |
Previously, ddaspit (Damien Daspit) wrote…
It should be ok - we recast as integers, not as strings. |
Previously, ddaspit (Damien Daspit) wrote…
It is in the standard health check - and there is no particular reason not to include it. |
Previously, ddaspit (Damien Daspit) wrote…
This is used for each of the sub-categories of checks:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did all of the .json, .ldml, .py files change?
Reviewed 23 of 23 files at r2, all commit messages.
Reviewable status: all files reviewed, 14 unresolved discussions (waiting on @johnml1135)
samples/EchoTranslationEngine/TranslationEngineServiceV1.cs
line 3 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
It's the new net8.0 primary constructor.
I know. The line is going over the 120 character limit without wrapping. If you reformat this file with CSharpier, it should fix it.
src/Serval.ApiServer/Startup.cs
line 45 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
I see what I was doing - I was confusing the null forgiving operator in CSharp (!) with the not-null assertion operator in Kotlin (!!). I will change them to the
?? throw
syntax.
I would do this instead:
var dataFileOptions = new DataFileOptions();
Configuration.GetSection(DataFileOptions.Key).Bind(dataFileOptions);
Previously, ddaspit (Damien Daspit) wrote…
The exception literally captures exceptions - which sometimes can be used for debugging. They would be on the logs - but again, if it is already included, why not? |
Previously, ddaspit (Damien Daspit) wrote…
Done |
Previously, ddaspit (Damien Daspit) wrote…
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 13 unresolved discussions (waiting on @johnml1135)
src/Serval.Grpc/Protos/serval/translation/v1/engine.proto
line 108 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
It should be ok - we recast as integers, not as strings.
Yes, but it is inconsistent with the rest of the API definition.
src/Serval.Grpc/Protos/serval/translation/v1/engine.proto
line 109 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
It is in the standard health check - and there is no particular reason not to include it.
It is in the standard health check for .NET, but this API could be implemented by some other tech stack. I would like to make this as easy as possible to be implemented.
src/Serval.Grpc/Protos/serval/translation/v1/engine.proto
line 111 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
The exception literally captures exceptions - which sometimes can be used for debugging. They would be on the logs - but again, if it is already included, why not?
By calling it exception
, we are assuming a particular language construct. One that some languages might not have. This API is intended to be language-agnostic.
Previously, ddaspit (Damien Daspit) wrote…
I think it was needed. I changed it because net8.0 complained about passing the exception. I needed to switch the order of exception and message to make the function happy - done. |
Previously, ddaspit (Damien Daspit) wrote…
I used it more places before - you are right. |
Previously, ddaspit (Damien Daspit) wrote…
I thought we needed them more places - for sharing with machine - when I was doing the rest endpoints. I'll move them back. |
I ran formatting - I'll check the files again. They changed more than I was expecting and I will revert at least the ldml. |
Previously, ddaspit (Damien Daspit) wrote…
csharpier doesn't handle primary constructors in C#12 yet - it can only handle C#11. I am reverting all the new primary constructors to preserve csharpier working. |
Previously, ddaspit (Damien Daspit) wrote…
What about for connection strings? Shouldn't we fail if one is not actively defined? |
Previously, ddaspit (Damien Daspit) wrote…
updated - it works magically, making the C# classes names as camel case already. |
Previously, ddaspit (Damien Daspit) wrote…
Is making it optional good enough? |
Previously, johnml1135 (John Lambert) wrote…
It isn't needed at all - the Health check function creates it's own duration independent of any data passed. I'll remove it. |
Previously, ddaspit (Damien Daspit) wrote…
Error is fine enough. We can map it to exception at the C# Health Check level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 14 of 14 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @johnml1135)
samples/EchoTranslationEngine/TranslationEngineServiceV1.cs
line 3 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
csharpier doesn't handle primary constructors in C#12 yet - it can only handle C#11. I am reverting all the new primary constructors to preserve csharpier working.
It seems to work fine with primary constructors once I updated to the latest version.
src/Serval.ApiServer/Startup.cs
line 45 at r1 (raw file):
Previously, johnml1135 (John Lambert) wrote…
What about for connection strings? Shouldn't we fail if one is not actively defined?
Yes.
src/Serval.ApiServer/Startup.cs
line 50 at r3 (raw file):
Configuration.GetSection(DataFileOptions.Key).Bind(dataFileOptions); // find drive letter for DataFilesDir string driveLetter = Path.GetPathRoot(dataFileOptions.FilesDirectory)![..1];
You missed removing the null-forgiving operator here.
src/Serval.Shared/Configuration/IServalBuilderExtensions.cs
line 48 at r3 (raw file):
var mongoConnectionString = builder.Configuration?.GetConnectionString("Mongo") ?? throw new Exception("Mongo connection string not configured");
I generally try to avoid throwing Exception
. InvalidOperationException
would be fine in this case. Also, please avoid the ?? throw
syntax. I don't think it is as clear as a normal if
statement.
Previously, ddaspit (Damien Daspit) wrote…
It's working for me now as well - it may be a new release. I'll update. |
Previously, ddaspit (Damien Daspit) wrote…
Fixed |
* Caching still doesn't work !?!?!
…n make auth'd work, but we don't need to, or really want to.)
1f52812
to
4426945
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 23 of 23 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @johnml1135)
samples/EchoTranslationEngine/EchoTranslationEngine.csproj
line 16 at r4 (raw file):
<ItemGroup> <ProjectReference Include="..\..\src\Serval.Grpc\Serval.Grpc.csproj" /> <ProjectReference Include="..\..\src\Serval.Shared\Serval.Shared.csproj" />
Why was this added back?
Previously, ddaspit (Damien Daspit) wrote…
By accident - I removed the commit that did all the mis-formatting of files and must have removed that change from it. |
Previously, ddaspit (Damien Daspit) wrote…
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @johnml1135)
Resolves sillsdev/machine#141 and #243.
This change is