AspNetCore.Diagnostics.HealthChecks
AspNetCore.Diagnostics.HealthChecks copied to clipboard
Health check fails for AspNetCore.HealthChecks.Elasticsearch:9.0.0
What happened:
Health check doesn't work due to transitive dependency issue:
[16:28:09] fail: Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService[104]
Health check elasticsearch threw an unhandled exception after 2.8406ms
System.TypeLoadException: Could not load type 'Elastic.Transport.TransportConfigurationBase`1' from assembly 'Elastic.Transport, Version=0.0.0.0, Culture=neutral, PublicKeyToken=069ca2728db333c1'.
at HealthChecks.Elasticsearch.ElasticsearchHealthCheck.CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at HealthChecks.Elasticsearch.ElasticsearchHealthCheck.CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken)
at Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService.RunCheckAsync(HealthCheckRegistration registration, CancellationToken cancellationToken)
This happens because we have a dependency on Elastic.Clients.Elasticsearch:8.16.3 which resolves transitive dependency to Elastic.Transport:0.5.7
What you expected to happen:
Health check should work as expected.
How to reproduce it (as minimally and precisely as possible):
Add to a project that references Elastic.Clients.Elasticsearch:8.16.3 and AspNetCore.HealthChecks.Elasticsearch:9.0.0 at the same time.
cc @Alirexaa @flobernd
Our transport library Elastic.Transport is still in "pre-release" state (0.x.x version) which is bad, looking at this issue and other problems caused by the breaking changes that propagate to the Elastic.Clients.Elasticsearch package.
We are working on releasing a final version 1.0.0 for Elastic.Transport soon.
For now, there is not much we can do. It would probably be best to bump the Elasticsearch client package dependency in the next release of AspNetCore.HealthChecks.Elasticsearch.
We are working on releasing a final version 1.0.0 for Elastic.Transport soon.
@flobernd Please ping us once it's available, we are then going to bump it and release a new version. Thanks!
should ? new ElasticsearchClientSettings(_options.CloudId!, new ApiKey(_options.ApiKey!)) be ? new ElasticsearchClientSettings(_options.CloudId!, new ApiKey(_options.CloudApiKey!))
Is there some workaround in the meantime?
@kaidl downgrade to AspNetCore.HealthChecks.Elasticsearch 8.0.1
Any news about this bug resolution for dotnet .9?
@flobernd any further news on the Elastic.Transport update?
@cjlotz We planned to release Elastic.Transport 1.0 last week, but a few final pieces are still missing. I assume we will be ready in the beginning of April.
Any update on this so far? I am experience this issue in my web API health checks endpoint
Hi there, very sorry for the delay. We recently released Elasticsearch 9 which took more time than expected. Besides that, we have a lot of PTO and maternity/paternity leave at the moment in the .NET team. Just letting you know that we did not forget about this.
Hi every one, Is it also possible to add UseClusterHealthApi to extension method https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/blob/master/src/HealthChecks.Elasticsearch/DependencyInjection/ElasticsearchHealthCheckBuilderExtensions.cs#L98 and add it as option here https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/blob/master/src/HealthChecks.Elasticsearch/DependencyInjection/ElasticsearchHealthCheckBuilderExtensions.cs#L115
How is it going with fix?
We still did not release 1.0.0 of the transport library, but at this point chances of breaking interface changes are very very low.
I would recommend to update to the latest 8.19.x Elasticsearch client. This is the LTS version that is compatible with Elasticsearch 8 and 9 clusters and probably the version that most users will be using for now (unless they specifically require Elasticsearch 9 features).
The transport library will be kept in sync between 8.19.x and 9.x.x client releases which will hopefully prevent dependency conflicts in the future.
cc @adamsitnik @Alirexaa
@flobernd Any update on the fix?