-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Fix active_shards_percent_as_number NaN when total shard count is zero #134807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
💚 CLA has been signed |
I have already signed the CLA. If I missed anything, please let me know. Please review, thanks a lot! |
Pinging @elastic/es-data-management (Team:Data Management) |
this.activeShardsPercent = 100.0; | ||
} else { | ||
this.activeShardsPercent = (((double) this.activeShards) / totalShardCount) * 100; | ||
this.activeShardsPercent = totalShardCount == 0 ? 0.0 : (((double) this.activeShards) / totalShardCount) * 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that perhaps we should represent this as 100%, rather than 0%, since the cluster would be totally healthy if there were no shards. 0% would indicate otherwise to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should do this. If there are indices in the metadata but no routing table then the index is totally unassigned. The only way we can get here is if we skip over those indices here:
elasticsearch/server/src/main/java/org/elasticsearch/cluster/health/ClusterStateHealth.java
Lines 89 to 91 in ffe911b
if (indexRoutingTable == null) { | |
continue; | |
} |
That probably made sense prior to #33888 but these days it doesn't, the only time you can get here is in a freshly-started cluster, and for that we should be saying the health is red
and the assigned percentage is 0
.
I think we should drop that null check and instead make the constructor of org.elasticsearch.cluster.health.ClusterIndexHealth
handle a null routing table by treating it as if all the shards are unassigned.
Thanks for the review @dakrone @DaveCTurner |
Please review, thanks! |
In this PR I attempt to fix #134806.
Details see: #134806.