Prevent traffic before storage initialization#5669
Draft
mikaelweave wants to merge 2 commits into
Draft
Conversation
Return an unhealthy health check while storage initialization is incomplete so Kubernetes does not route requests to a pod whose search parameters and SQL model are not ready. AB#197936 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ff23dc3f-596e-4d5b-b473-bc30ddb1684b
mikaelweave
commented
Jul 11, 2026
| TimeSpan waited = Clock.UtcNow - _started; | ||
| if (waited < TimeSpan.FromMinutes(5)) | ||
| { | ||
| return Task.FromResult(new HealthCheckResult(HealthStatus.Degraded, $"Storage is initializing. Waited: {(int)waited.TotalSeconds}s.")); |
Contributor
Author
There was a problem hiding this comment.
IMPORTANT - we cannot return 200 from health check until the storage is initialized, else containers will have traffic routed and will return 503.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5669 +/- ##
==========================================
+ Coverage 77.52% 77.54% +0.01%
==========================================
Files 1004 1006 +2
Lines 36924 36964 +40
Branches 5600 5605 +5
==========================================
+ Hits 28627 28662 +35
- Misses 6938 6946 +8
+ Partials 1359 1356 -3 🚀 New features to boost your workflow:
|
AB#197936 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ff23dc3f-596e-4d5b-b473-bc30ddb1684b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Returns an unhealthy health check while storage initialization is incomplete, preventing Kubernetes from routing traffic before search parameters and the SQL FHIR model are ready.
Related issues
AB#197936
Testing
dotnet test src\Microsoft.Health.Fhir.Api.UnitTests\Microsoft.Health.Fhir.R4.Api.UnitTests.csproj --no-restore --filter FullyQualifiedName~StorageInitializedHealthCheckTestsFHIR Team Checklist
Semver Change
Patch