[HealthAPI] Deterministic shard availability key order#138260
Conversation
|
Pinging @elastic/es-data-management (Team:Data Management) |
|
buildkite test this |
|
buildkite test this |
|
hi @madalynbartman, thank you for your interest in Elasticsearch! i have some questions:
|
|
@szybia I added some logic to sort projects by ID and indices by name before processing so they come out in a deterministic order then took a page out of your book and tested on a local three node cluster. Please review the latest commit and let me know if I need to adjust something. Appreciate your feedback and patience! Was your second point asking me to create a unit test for this? I can give it a shot, but to be honest, Im a bit out of my depth there and might need to learn more about the API before doing so. |
|
@madalynbartman hmmm, i still don't quite think your changes do what i believe we want to do here i tried this out myself and here's what i came up with: https://github.com/elastic/elasticsearch/compare/main...szybia:elasticsearch:deterministic-shards-health?diff=unified&w if you agree this solves our problem, maybe you can apply something like my changes into this PR |
|
@szybia Tried it out and it worked perfectly. I agree with that approach, thanks for walking me through it. Pushed those changes |
...lasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java
Show resolved
Hide resolved
62861bf to
4bc30d6
Compare
|
Can I please get another review when you get a chance? @szybia |
szybia
left a comment
There was a problem hiding this comment.
i believe still a few remnants after your initial approach, unless i'm mistaken 🤔 let me know what you think!
...lasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java
Outdated
Show resolved
Hide resolved
...lasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java
Outdated
Show resolved
Hide resolved
|
@szybia agreed! Just need the LinkedHashMap in getDetails(). Reverted the others |
|
@szybia Would you mind taking another look when you get a chance? |
...lasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java
Show resolved
Hide resolved
...lasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR addresses deterministic ordering of shard availability keys in the Health API by replacing HashMap with LinkedHashMap. The change ensures that health indicator details are returned with a predictable key order, which is important for API consistency and testing.
Key Changes:
- Modified
ShardsAvailabilityHealthIndicatorServiceto useLinkedHashMapfor deterministic key ordering in health indicator details - Added comprehensive test coverage to verify the key order matches the expected sequence
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ShardsAvailabilityHealthIndicatorService.java | Refactored getDetails() method to use LinkedHashMap instead of Map.of() for deterministic key ordering |
| ShardsAvailabilityHealthIndicatorServiceTests.java | Added test case to verify deterministic ordering of shard availability keys |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...lasticsearch/cluster/routing/allocation/shards/ShardsAvailabilityHealthIndicatorService.java
Show resolved
Hide resolved
samxbr
left a comment
There was a problem hiding this comment.
LGTM, we can merge after the change log is added and CI is passed. Thank you for contributing to Elasticsearch!
…astic#138043' of https://github.com/madalynbartman/elasticsearch into HealthAPI-Deterministic-shard-availability-key-order-elastic#138043
|
Added change log |
|
buildkite test this |
|
thank you for contributing to Elasticsearch! |
This PR replaces HashMap with LinkedHashMap for deterministic ordering.
Tested by running gradlew :server:test --tests "ShardsAvailabilityHealthIndicatorServiceTests" --no-daemon, gradlew :server:test --tests "Health" --no-daemon, and gradlew check --no-daemon.
Closes #138043