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

Read min cluster version directly from DiscoveryNodes #581

Conversation

martin-gaievski
Copy link
Member

Signed-off-by: Martin Gaievski [email protected]

Description

Found simpler way of reading min deployed version for cluster, we can remove direct iteration over cluster nodes - https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java#L399. Changing that for context of filtering feature.

Issues Resolved

#376

Check List

  • All tests pass
  • Commits are signed as per the DCO using --signoff

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.

@martin-gaievski martin-gaievski added Enhancements Increases software capabilities beyond original client specifications 2.4.0 feature branch labels Oct 14, 2022
@martin-gaievski martin-gaievski requested a review from a team October 14, 2022 18:54
@codecov-commenter
Copy link

Codecov Report

Merging #581 (72996bb) into feature/efficient-filtering (2e18ae8) will decrease coverage by 0.28%.
The diff coverage is 100.00%.

@@                        Coverage Diff                        @@
##             feature/efficient-filtering     #581      +/-   ##
=================================================================
- Coverage                          84.38%   84.09%   -0.29%     
+ Complexity                          1055     1048       -7     
=================================================================
  Files                                149      149              
  Lines                               4316     4308       -8     
  Branches                             384      382       -2     
=================================================================
- Hits                                3642     3623      -19     
- Misses                               499      508       +9     
- Partials                             175      177       +2     
Impacted Files Coverage Δ
...va/org/opensearch/knn/index/KNNClusterContext.java 100.00% <100.00%> (ø)
...va/org/opensearch/knn/index/KNNCircuitBreaker.java 60.00% <0.00%> (-20.00%) ⬇️
...ain/java/org/opensearch/knn/index/KNNSettings.java 80.88% <0.00%> (-2.21%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@@ -49,20 +46,11 @@ public void initialize(final ClusterService clusterService) {
*/
public Version getClusterMinVersion() {
Version minVersion = Version.CURRENT;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Version minVersion = Version.CURRENT;
public Version getClusterMinVersion() {
try {
return this.clusterService.state().getNodes().getMinNodeVersion();
} catch (Exception exception) {
log.error("Failed to get minimum node version of the cluster. Returning current node version instead.", exception);
return Version.CURRENT;
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Trivial. Better not to change variable value once it is defined to reduce a chance of an error.

Copy link
Member Author

Choose a reason for hiding this comment

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

ack

try {
clusterDiscoveryNodes = this.clusterService.state().getNodes().getNodes();
minVersion = this.clusterService.state().getNodes().getMinNodeVersion();
} catch (Exception exception) {
log.error("Cannot get cluster nodes", exception);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Error message needs to be updated.

@martin-gaievski martin-gaievski merged commit 9b32e17 into opensearch-project:feature/efficient-filtering Oct 14, 2022
martin-gaievski added a commit to martin-gaievski/k-NN that referenced this pull request Oct 20, 2022
…ject#581)

* Simplify min cluster version lookup

Signed-off-by: Martin Gaievski <[email protected]>
@heemin32 heemin32 added v2.4.0 'Issues and PRs related to version v2.4.0' and removed 2.4.0 labels Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancements Increases software capabilities beyond original client specifications feature branch v2.4.0 'Issues and PRs related to version v2.4.0'
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants