Skip to content

Commit

Permalink
fix: set readiness check to degraded when pollster does not process t…
Browse files Browse the repository at this point in the history
…asks (#695)
  • Loading branch information
lemaitre-aneo authored Apr 23, 2024
2 parents c2e1091 + a4b0aed commit 556fcb8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Common/src/Pollster/Pollster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ public async Task<HealthCheckResult> Check(HealthCheckTag tag)
healthCheckFailedResult_ = result;
}

if (tag == HealthCheckTag.Readiness && taskProcessingDict_.IsEmpty)
{
return HealthCheckResult.Unhealthy("No tasks to process");
}

return result;
}

Expand Down
3 changes: 2 additions & 1 deletion Common/tests/Pollster/PollsterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ await testServiceProvider.Pollster.Init(CancellationToken.None)
Assert.AreEqual(HealthStatus.Healthy,
(await testServiceProvider.Pollster.Check(HealthCheckTag.Liveness)
.ConfigureAwait(false)).Status);
Assert.AreEqual(HealthStatus.Healthy,
// Unhealthy because there are no tasks in queue
Assert.AreEqual(HealthStatus.Unhealthy,
(await testServiceProvider.Pollster.Check(HealthCheckTag.Readiness)
.ConfigureAwait(false)).Status);
Assert.AreEqual(HealthStatus.Healthy,
Expand Down

0 comments on commit 556fcb8

Please sign in to comment.