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

Add search node repurpose commands #6517

Merged
merged 1 commit into from
Mar 11, 2023

Conversation

kotwanikunal
Copy link
Member

Description

  • Add repurpose command support for search node reutilization

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

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.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2023

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2023

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2023

Codecov Report

Merging #6517 (8afcc8a) into main (13d336c) will increase coverage by 0.00%.
The diff coverage is 68.22%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff            @@
##               main    #6517   +/-   ##
=========================================
  Coverage     70.79%   70.80%           
- Complexity    59121    59166   +45     
=========================================
  Files          4804     4804           
  Lines        283141   283210   +69     
  Branches      40815    40841   +26     
=========================================
+ Hits         200462   200531   +69     
+ Misses        66229    66208   -21     
- Partials      16450    16471   +21     
Impacted Files Coverage Δ
.../java/org/opensearch/env/NodeRepurposeCommand.java 75.00% <67.30%> (-14.89%) ⬇️
.../main/java/org/opensearch/env/NodeEnvironment.java 77.93% <100.00%> (+1.46%) ⬆️

... and 502 files with indirect coverage changes

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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2023

Gradle Check (Jenkins) Run Completed with:

processNoClusterManagerNoDataNode(terminal, dataPaths, env);
} else {
processClusterManagerNoDataNode(terminal, dataPaths, env);
if (DiscoveryNode.isDataNode(env.settings()) == false) {
Copy link
Member

Choose a reason for hiding this comment

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

What if both isDataNode and isSearchNode are false? This will only execute the first branch of the if statement. Is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea here was that it would operate in a step fashion, because the errors are thrown individually - https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/env/NodeEnvironment.java#L386-L396

The clients can perform the repurposing one at a time.
WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

So lets say I have a node that has been used as both a data and a search node and I want to repurpose it to be a cluster manager node. Does that mean I'd have to run the repurpose command twice?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, since the conditions are currently laid out differently within node startup.

Copy link
Member

Choose a reason for hiding this comment

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

But node startup doesn't have anything to do with this repurpose command though, right? If I run this command on a host that had multiple roles but now no longer has any of them, I would expect it to do the right thing and clear everything out. Is that difficult or not possible for some reason?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not difficult, just a bunch of combinatorial logic, which I was trying to avoid. I can add it in, shouldn't take a lot of time.

Copy link
Member

Choose a reason for hiding this comment

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

Does it have to be combinatorial? Like why can't it be:

if not data role:
  clean up data if exists
if not search role:
  clean up search if exists
...

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

@kotwanikunal kotwanikunal force-pushed the cache-reservation branch 3 times, most recently from 03a1fbb to e26cf31 Compare March 10, 2023 01:13
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Comment on lines +197 to +203
if (repurposeData && repurposeSearch) {
terminal.println("Node successfully repurposed to no-cluster-manager, no-data and no-search.");
} else if (repurposeData) {
terminal.println("Node successfully repurposed to no-cluster-manager and no-data.");
} else if (repurposeSearch) {
terminal.println("Node successfully repurposed to no-cluster-manager and no-search.");
}
Copy link
Member

Choose a reason for hiding this comment

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

Seems like you could avoid this explosion of cases with something like:

roleText.add("no-cluster-manager");
if (repurposeData) roleText.add("no-data");
if (repurposeSearch) roleText.add("no-search");
terminal.println("Node successfully repurposed to: " + String.join(",", roleText));

Same applies in the other cases though might require more refactoring. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought of doing that, but this makes it more readable and traceable. Given its use case and frequency of use, I think we would rather benefit from this approach.

@andrross andrross merged commit 71a76da into opensearch-project:main Mar 11, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 11, 2023
Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
(cherry picked from commit 71a76da)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
kotwanikunal pushed a commit that referenced this pull request Mar 11, 2023
(cherry picked from commit 71a76da)

Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
mingshl pushed a commit to mingshl/OpenSearch-Mingshl that referenced this pull request Mar 24, 2023
Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
Signed-off-by: Mingshi Liu <mingshl@amazon.com>
@kotwanikunal kotwanikunal deleted the cache-reservation branch May 12, 2023 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants