AspNetCore.Diagnostics.HealthChecks icon indicating copy to clipboard operation
AspNetCore.Diagnostics.HealthChecks copied to clipboard

Health check fails for AspNetCore.HealthChecks.Elasticsearch:9.0.0

Open NikiforovAll opened this issue 11 months ago • 12 comments

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.

NikiforovAll avatar Dec 30 '24 14:12 NikiforovAll

cc @Alirexaa @flobernd

adamsitnik avatar Jan 13 '25 13:01 adamsitnik

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.

flobernd avatar Jan 13 '25 15:01 flobernd

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!

adamsitnik avatar Jan 13 '25 15:01 adamsitnik

should ? new ElasticsearchClientSettings(_options.CloudId!, new ApiKey(_options.ApiKey!)) be ? new ElasticsearchClientSettings(_options.CloudId!, new ApiKey(_options.CloudApiKey!))

vik-torr avatar Jan 14 '25 19:01 vik-torr

Is there some workaround in the meantime?

kaidl avatar Jan 17 '25 09:01 kaidl

@kaidl downgrade to AspNetCore.HealthChecks.Elasticsearch 8.0.1

sergey-tihon avatar Jan 17 '25 09:01 sergey-tihon

Any news about this bug resolution for dotnet .9?

franciscolacerd avatar Mar 18 '25 16:03 franciscolacerd

@flobernd any further news on the Elastic.Transport update?

cjlotz avatar Mar 20 '25 13:03 cjlotz

@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.

flobernd avatar Mar 21 '25 12:03 flobernd

Any update on this so far? I am experience this issue in my web API health checks endpoint

ChrisClaude avatar Apr 30 '25 13:04 ChrisClaude

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.

flobernd avatar May 06 '25 07:05 flobernd

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

gortha avatar May 27 '25 15:05 gortha

How is it going with fix?

piotrlaczykowski avatar Aug 29 '25 07:08 piotrlaczykowski

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 avatar Aug 29 '25 07:08 flobernd

@flobernd Any update on the fix?

willyt150 avatar Nov 24 '25 17:11 willyt150