bagetter / BaGetter

A lightweight NuGet and symbol server
https://www.bagetter.com
MIT License
243 stars 53 forks source link

Expand Health Checks with database connection check #108

Open Hechamon opened 6 months ago

Hechamon commented 6 months ago

Is your feature request related to a problem? Please describe.

105 added a basic health check endpoint, which could be expanded upon

Describe the solution you'd like

BaGetter is only really healthy if the database is at least reachable, so let's check that The two ways of doing this which I can see are the following

Regenhardt commented 6 months ago

We can also add a button, or one button per service, to the statistics page where the services are listed to let the user trigger the health checks from the web app.

Regenhardt commented 6 months ago

Should the health check just return Healthy/Degraded/Unhealthy, or the actual services too? I could implement it so that if ListConfiguredServices is true, it returns a detailed report about which service is healthy, and otherwise just return Healthy/Degraded/Unhealthy and nothing else.

Or more uniform: Always a json object, but it contains either the general status only or includes services too:

{
  "BaGetter": "Healthy",
  "Sqlite": "Healthy"
}

Not sure if "BaGetter" is clear enough or if something like "OverallStatus" or completely different would be better, as that value represents the aggregated result of all health checks.

Regenhardt commented 6 months ago

Or just "Status".

seriouz commented 6 months ago

I would go with Status and the ListConfiguredServices idea:

{
   "Status": "Healthy"
}

If atleast one service fails Status is unhealthy too.

{
   "Status": "Unhealthy",
   "MySql": "Unhealthy"
}

Or the app is somehow unhealty itself but the DB is healthy:

{
   "Status": "Unealthy",
   "MySql": "Healthy"
}
Regenhardt commented 6 months ago

Just tried it: the status property is automatically unhealthy when at least one other health check is unhealthy.

Regenhardt commented 6 months ago

This first feature includes db checks and usage of all configured and registered checks.

This means we can now easily add additional health checks for single providers and they will be used, but we don't have to add all at once.

I propose to add another extension method to the core to add a storage health check that makes sure it's registered with the correct name, which each individual provider's activating extension can then call with its own specific implementation, similar to the AddSqlServer etc. methods. Not entirely sure about this one yet.

I see AWS has its own health check package and function, maybe other providers have that too.

github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 90 days with no activity. Remove the stale label, comment, or this will be closed in 5 days.