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

Disallow multiple data paths for search nodes #6427

Conversation

xuezhou25
Copy link
Contributor

Description

At node bootstrap, check if the node has search role and multiple data paths, if yes, fail the bootstrap.

Issues Resolved

resolve #6274

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.

@xuezhou25 xuezhou25 force-pushed the Prevent_search_node_startup_for_multiple_data_path branch from e4c972e to d1a7b87 Compare February 22, 2023 00:45
@@ -774,4 +779,22 @@ Version getVersion() {
version.set(Runtime.version());
BootstrapChecks.check(emptyContext, true, Collections.singletonList(check));
}

public void testMultipleDataPathCheck() throws NodeValidationException {
Copy link
Member

Choose a reason for hiding this comment

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

I think there should be 3 cases here:

  1. search node, 1 data path
  2. search node, 2 data paths
  3. data node, 2 data paths

You have case 2 covered, but not really the other two. They should be separate test methods as well because it is generally a best practice to make each test case test one thing whenever possible.

Copy link
Contributor Author

@xuezhou25 xuezhou25 Feb 22, 2023

Choose a reason for hiding this comment

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

Got it! Thanks for the reviews Andrew :)

CHANGELOG.md Outdated
@@ -101,6 +101,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix timeout error when adding a document to an index with extension running ([#6275](https://github.com/opensearch-project/OpenSearch/pull/6275))
- Handle translog upload during primary relocation for remote-backed indexes ([#5804](https://github.com/opensearch-project/OpenSearch/pull/5804))
- Batch translog sync/upload per x ms for remote-backed indexes ([#5854](https://github.com/opensearch-project/OpenSearch/pull/5854))
- Add bootstrap check to avoid search node has multiple data paths ([#6427](https://github.com/opensearch-project/OpenSearch/pull/6427))
Copy link
Member

Choose a reason for hiding this comment

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

I'd call this "Disallow multiple data paths for search nodes". Please update the commit message and PR title as well.

/**
* Bootstrap check that if a search node contains multiple data paths
*/
static class MultipleDataPathCheck implements BootstrapCheck {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be private?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why should this class be private? I think it is reasonable to be default

Copy link
Member

Choose a reason for hiding this comment

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

The answer to my question is "no" because it is referenced in the unit test, which I missed when I made this comment :)

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@dreamer-89
Copy link
Member

dreamer-89 commented Feb 22, 2023

Gradle Check (Jenkins) Run Completed with:

Looks like a legit failure @xuezhou25

REPRODUCE WITH: ./gradlew ':server:test' --tests "org.opensearch.bootstrap.BootstrapChecksTests.testMultipleDataPathCheck" -Dtests.seed=ED64E1E8740B72F -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=sr -Dtests.timezone=Europe/Budapest -Druntime.java=19

org.opensearch.bootstrap.BootstrapChecksTests > testMultipleDataPathCheck FAILED
    java.lang.AssertionError: 
    Expected: a string containing "Having multiple data paths in the search role is not allowed"
         but: was "[1] bootstrap checks failed
    [1]: Having multiple data paths in the search node is not allowed"
        at __randomizedtesting.SeedInfo.seed([ED64E1E8740B72F:A2E0146960C4CA10]:0)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
        at org.junit.Assert.assertThat(Assert.java:964)
        at org.junit.Assert.assertThat(Assert.java:930)
        at org.opensearch.bootstrap.BootstrapChecksTests.testMultipleDataPathCheck(BootstrapChecksTests.java:796)

);
final List<BootstrapCheck> checks = Collections.singletonList(new BootstrapChecks.MultipleDataPathCheck());
final NodeValidationException e = expectThrows(NodeValidationException.class, () -> BootstrapChecks.check(context, true, checks));
assertThat(e.getMessage(), containsString("Having multiple data paths in the search role is not allowed"));
Copy link
Member

Choose a reason for hiding this comment

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

nit: assertThat -> assertEquals

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is preferable to use assertThat due to #2503 (review)

Copy link
Member

Choose a reason for hiding this comment

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

Isn't assertThat deprecated?

Copy link
Member

Choose a reason for hiding this comment

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

org.junit.Assert.assertThat() is deprecated (which OpenSearchTestCase ultimately inherits from). org.hamcrest.MatcherAssert.assertThat is not deprecated and is the intended replacement for that.

@xuezhou25 xuezhou25 changed the title Add bootstrap check to avoid search node has multiple data paths Disallow multiple data paths for search nodes Feb 23, 2023
@opensearch-project opensearch-project deleted a comment from github-actions bot Feb 23, 2023
@opensearch-project opensearch-project deleted a comment from github-actions bot Feb 23, 2023
Signed-off-by: Xue Zhou <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

codecov-commenter commented Feb 23, 2023

Codecov Report

Merging #6427 (c9ff4d1) into main (4dd0c5f) will decrease coverage by 0.06%.
The diff coverage is 87.50%.

📣 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    #6427      +/-   ##
============================================
- Coverage     70.76%   70.70%   -0.06%     
+ Complexity    59093    59056      -37     
============================================
  Files          4802     4800       -2     
  Lines        282793   282719      -74     
  Branches      40782    40765      -17     
============================================
- Hits         200111   199906     -205     
- Misses        66271    66420     +149     
+ Partials      16411    16393      -18     
Impacted Files Coverage Δ
...va/org/opensearch/cluster/routing/RoutingNode.java 78.53% <ø> (-0.26%) ⬇️
...ting/allocation/allocator/LocalShardsBalancer.java 85.13% <ø> (-0.10%) ⬇️
...r/routing/allocation/allocator/ShardsBalancer.java 33.33% <ø> (+8.33%) ⬆️
...search/common/settings/AbstractScopedSettings.java 88.38% <ø> (+1.25%) ⬆️
...rg/opensearch/common/settings/ClusterSettings.java 91.89% <ø> (ø)
...n/java/org/opensearch/common/settings/Setting.java 86.13% <ø> (-0.22%) ⬇️
...java/org/opensearch/bootstrap/BootstrapChecks.java 89.87% <85.71%> (+0.71%) ⬆️
.../allocation/allocator/BalancedShardsAllocator.java 91.17% <85.71%> (+0.60%) ⬆️
...egations/support/MultiTermsValuesSourceConfig.java 80.32% <100.00%> (ø)
...egations/support/MultiValuesSourceFieldConfig.java 92.50% <100.00%> (ø)
... and 510 more

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

final List<BootstrapCheck> checks = Collections.singletonList(new BootstrapChecks.MultipleDataPathCheck());
final NodeValidationException e = expectThrows(NodeValidationException.class, () -> BootstrapChecks.check(context, true, checks));
assertThat(e.getMessage(), containsString("Having multiple data paths in the search node is not allowed"));
}
Copy link
Contributor

@gashutos gashutos Feb 23, 2023

Choose a reason for hiding this comment

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

Would this kind of private method help to remove some duplicate effort ?

public void performDataPathsCheck(String[] paths, String roleName) throws NodeValidationException {
         final BootstrapContext context = createTestContext(
            Settings.builder()
                .putList(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), Collections.singletonList(roleName))
                .putList(Environment.PATH_DATA_SETTING.getKey(), paths)
                .build(),
            Metadata.EMPTY_METADATA
        );
        final List<BootstrapCheck> checks = Collections.singletonList(new BootstrapChecks.MultipleDataPathCheck());
        BootstrapChecks.check(emptyContext, true, checks);
    }

Copy link
Member

@andrross andrross left a comment

Choose a reason for hiding this comment

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

Looking pretty good! Just a couple minor issues.

public BootstrapCheckResult check(BootstrapContext context) {
if (NodeRoleSettings.NODE_ROLES_SETTING.get(context.settings()).contains(DiscoveryNodeRole.SEARCH_ROLE)
&& Environment.PATH_DATA_SETTING.get(context.settings()).size() > 1) {
return BootstrapCheckResult.failure("Having multiple data paths in the search node is not allowed");
Copy link
Member

Choose a reason for hiding this comment

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

Another nitpick on the wording, but something like "Multiple data paths are not allowed for search nodes" is probably a bit clearer and more direct.

Signed-off-by: Xue Zhou <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Xue Zhou <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@andrross andrross merged commit ceb3928 into opensearch-project:main Feb 23, 2023
@andrross andrross added the backport 2.x Backport to 2.x branch label Feb 23, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 23, 2023
Add bootstrap check to avoid search node has multiple data path

Signed-off-by: Xue Zhou <[email protected]>
(cherry picked from commit ceb3928)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
andrross pushed a commit that referenced this pull request Feb 24, 2023
Add bootstrap check to avoid search node has multiple data path


(cherry picked from commit ceb3928)

Signed-off-by: Xue Zhou <[email protected]>
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>
@xuezhou25 xuezhou25 deleted the Prevent_search_node_startup_for_multiple_data_path branch February 24, 2023 01:57
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.

[Searchable Snapshots] Prevent search node startup if there are more than a single data path
6 participants