Skip to content
This repository was archived by the owner on Dec 8, 2018. It is now read-only.
This repository was archived by the owner on Dec 8, 2018. It is now read-only.

Nested paths screw up health check filters #511

@jmezach

Description

@jmezach

I'm not sure if this is even supposed to work, but it's just something I noticed while I was exploring the health checks feature. In my ConfigureServices I have the following:

services.AddHealthChecks()
        .AddCheck("MyDatabase",
                  new SqlConnectionHealthCheck("Data Source=localhost;Initial Catalog=my-dummy-database"),
                  tags: new[] { "ready" });

Obviously the SqlConnectionHealthCheck fails because it cannot connect to the database (in fact, there isn't even a SQL Server running on my machine). Now I have added the following to my Configure method:

app.UseHealthChecks("/health", new HealthCheckOptions {});

app.UseHealthChecks("/health/ready", new HealthCheckOptions
{
  Predicate = (check) => check.Tags.Contains("ready"), 
});

app.UseHealthChecks("/health/live", new HealthCheckOptions()
{
  Predicate = (check) => false,
});

In this setup I would expect /health to return Unhealthy, since it runs the SqlConnectionHealthCheck and it fails. This is indeed the case. The same goes for the /health/ready endpoint. However, I was expecting /health/live to return Healthy, but it does not. Instead it returns Unhealthy and looking at the log it seems to be executing the SqlConnectionHealthCheck regardless of the predicate.

Personally I would be fine with it if this is something that's not supported, but it might be useful to put this into the documentation somewhere so that users of this feature don't get tripped up.

Metadata

Metadata

Assignees

Labels

3 - DonePRI: 0 - CriticalBlocks a critical product path. Must be handled immediatelybug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions