Skip to content
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

Fix weight calculation of decideRebalance when explain #17720

Conversation

HUSTERGS
Copy link
Contributor

Description

The explain api POST _cluster/allocation/explain, explains how an allocation decision is made, but during the calculation of currentWeight in


, it uses original weight function which does not consider allocation/rebalance constraint:
// balance the shard, if a better node can be found
final String idxName = shard.getIndexName();
final float currentWeight = weight.weight(this, currentNode, idxName);
final AllocationDeciders deciders = allocation.deciders();
Decision.Type rebalanceDecisionType = Decision.Type.NO;

However the following calculation uses the new weightWithRebalanceConstraints, which is correct
// that should be on each node on average (both taking the cluster as a whole into account
// as well as shards per index)
final float nodeWeight = weight.weightWithRebalanceConstraints(this, node, idxName);
// if the node we are examining has a worse (higher) weight than the node the shard is
// assigned to, then there is no way moving the shard to the node with the worse weight

So change the former calculation of currentNode weight to use the new weightWithRebalanceConstraints function

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Contributor

❌ Gradle check result for 01331d5: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

@alchemist51 alchemist51 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes looks good to me!

@HUSTERGS HUSTERGS closed this Apr 3, 2025
@HUSTERGS HUSTERGS reopened this Apr 3, 2025
Copy link
Contributor

github-actions bot commented Apr 3, 2025

❌ Gradle check result for 01331d5: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@HUSTERGS HUSTERGS closed this Apr 3, 2025
@HUSTERGS HUSTERGS reopened this Apr 3, 2025
Copy link
Contributor

github-actions bot commented Apr 3, 2025

❕ Gradle check result for 01331d5: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

Copy link

codecov bot commented Apr 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.53%. Comparing base (399188f) to head (01331d5).
Report is 17 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #17720      +/-   ##
============================================
+ Coverage     72.46%   72.53%   +0.06%     
- Complexity    65855    65921      +66     
============================================
  Files          5322     5322              
  Lines        305477   305477              
  Branches      44312    44312              
============================================
+ Hits         221359   221572     +213     
+ Misses        66023    65729     -294     
- Partials      18095    18176      +81     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bugmakerrrrrr bugmakerrrrrr merged commit b5195f4 into opensearch-project:main Apr 3, 2025
110 of 116 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants