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 read_only block argument to opensearch-node unsafe-bootstrap command #599

Conversation

harmishlakhani
Copy link
Contributor

@harmishlakhani harmishlakhani commented Apr 22, 2021

…p command

Signed-off-by: Harmish Lakhani harmish.lakhani@gmail.com

Description

This change will add one optional argument to opensearch-node unsafe-bootstrap command known as apply-cluster-read-only-block. It will apply read only block to cluster based on its value (true or false) after successful bootstrap.

Usage : ./bin/opensearch-node unsafe-bootstrap --apply-cluster-read-only-block true

Older PR for previous conversations
#493

Issues Resolved

closes: #492

Check List

  • [ x ] New functionality includes testing.
    • [ x ] All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • [ x ] Commits are signed 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.

…p command

Signed-off-by: Harmish Lakhani <harmish.lakhani@gmail.com>
@odfe-release-bot
Copy link

✅   Gradle Wrapper Validation success f9ccaab

@odfe-release-bot
Copy link

✅   DCO Check Passed f9ccaab

@odfe-release-bot
Copy link

❌   Gradle Precommit failure f9ccaab
Log 305

Signed-off-by: Harmish Lakhani <harmish.lakhani@gmail.com>
@odfe-release-bot
Copy link

✅   DCO Check Passed 46e5796

@odfe-release-bot
Copy link

✅   Gradle Wrapper Validation success 46e5796

@odfe-release-bot
Copy link

✅   Gradle Precommit success 46e5796

@saratvemulapalli
Copy link
Member

start gradle check

@saratvemulapalli saratvemulapalli self-assigned this Apr 27, 2021
@odfe-release-bot
Copy link

❌   Gradle Check failure 46e5796
Log 142

Reports 142

@saratvemulapalli
Copy link
Member

@harmishlakhani can you take a look at the gradle check?

@opensearch-ci-bot
Copy link
Collaborator

❌   DCO Check Failed e7cb4001039b8a80516ea612e693182777709950
Run ./dev-tools/signoff-check.sh remotes/origin/main e7cb4001039b8a80516ea612e693182777709950 to check locally
Use git commit with -s to add 'Signed-of-by: {EMAIL}' on impacted commits

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Wrapper Validation success e7cb4001039b8a80516ea612e693182777709950

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Precommit success e7cb4001039b8a80516ea612e693182777709950

…ad_only_block

Signed-off-by: Harmish Lakhani <harmish.lakhani@gmail.com>
…unsafe_bootstrap_read_only_block

Signed-off-by: Harmish Lakhani <harmish.lakhani@gmail.com>
@harmishlakhani harmishlakhani force-pushed the unsafe_bootstrap_read_only_block branch from e7cb400 to 6e77034 Compare May 4, 2021 07:05
@opensearch-ci-bot
Copy link
Collaborator

✅   DCO Check Passed 6e77034

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Wrapper Validation success 6e77034

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Precommit success 6e77034

@saratvemulapalli
Copy link
Member

start gradle check

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 6e77034
Log 155

Reports 155


private void removeBlock() {
if (isInternalCluster()) {
Settings settings = Settings.builder().putNull(Metadata.SETTING_READ_ONLY_SETTING.getKey()).build() ;
Copy link
Member

Choose a reason for hiding this comment

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

[minor]: extra space before ";"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted, fix will come in next commit.

@@ -235,20 +261,24 @@ public void test3MasterNodes2Failed() throws Exception {

logger.info("--> start 1st master-eligible node");
masterNodes.add(internalCluster().startMasterOnlyNode(Settings.builder()
.put(DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.getKey(), "0s")
.build())); // node ordinal 0
.put(DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.getKey(), "0s")
Copy link
Member

Choose a reason for hiding this comment

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

you have updated the indentation at multiple places?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IntelliJ automatically updated indentation. Do we have to import any specific rules for IntelliJ for code formatting or defaults are suffice ?

Copy link
Member

Choose a reason for hiding this comment

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

@saratvemulapalli can you help with this? Do we have specific code formatter?

Copy link
Member

Choose a reason for hiding this comment

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

Just use ./gradlew spotlessApply it will format all of the code with the rules the project has defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@saratvemulapalli Thanks, I have checked with that and build is passing successfully without any changes.
So I guess all formatting is according to project rules only. See my comment for build output.

@@ -321,9 +356,10 @@ public void test3MasterNodes2Failed() throws Exception {
detachCluster(environmentMaster3, false);

logger.info("--> start 2nd and 3rd master-eligible nodes and ensure 4 nodes stable cluster");
internalCluster().startMasterOnlyNode(master2DataPathSettings);
Copy link
Member

Choose a reason for hiding this comment

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

Earlier, it was providing the data path explicitly, why did we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not able to recall why I removed it but yes I will add it back.

@@ -122,7 +134,9 @@ protected void processNodePaths(Terminal terminal, Path[] dataPaths, int nodeLoc
Settings persistentSettings = Settings.builder()
.put(metadata.persistentSettings())
.put(UNSAFE_BOOTSTRAP.getKey(), true)
.put(Metadata.SETTING_READ_ONLY_SETTING.getKey(), applyClusterReadOnlyBlock)
Copy link
Member

Choose a reason for hiding this comment

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

if there is a cluster block already present in the cluster and user doesnt pass set it explicitly, then it will get removed unintentionally. It should add this block only if it is true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh nice catch, let me fix it.

…s existing settings

Signed-off-by: Harmish Lakhani <harmish.lakhani@gmail.com>
@opensearch-ci-bot
Copy link
Collaborator

✅   DCO Check Passed 1363ac4

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Wrapper Validation success 1363ac4

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Precommit success 1363ac4

Copy link
Member

@shwetathareja shwetathareja left a comment

Choose a reason for hiding this comment

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

Minor comments, otherwise LGTM

Comment on lines -64 to -66
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
Copy link
Member

Choose a reason for hiding this comment

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

revert all the un-necessary import changes due to intellij or check with @saratvemulapalli which code formatter to use.

Copy link
Contributor Author

@harmishlakhani harmishlakhani May 12, 2021

Choose a reason for hiding this comment

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

I guess IntelliJ has reformatted all changes according to project rules only. See below check which is passing.

┌[kiwish-4.2]-(workplace/harmishlakhani-OpenSearch)-[git:unsafe_bootstrap_read_only_block]-
└> ./gradlew spotlessApply

> Configure project :
========================= WARNING =========================
         Backwards compatibility tests are disabled!
See https://github.com/opensearch-project/OpenSearch/issues/105
===========================================================

> Configure project :qa:os
Cannot add task 'destructiveDistroTest.docker' as a task with that name already exists.
=======================================
OpenSearch Build Hamster says Hello!
  Gradle Version        : 6.6.1
  OS Info               : Mac OS X 10.15.7 (x86_64)
  Runtime JDK Version   : 11 (JDK)
  Runtime java.home     : /Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home
  Gradle JDK Version    : 15 (JDK)
  Gradle java.home      : /Library/Java/JavaVirtualMachines/amazon-corretto-15.jdk/Contents/Home
  Random Testing Seed   : 6884CF4EAA1728F3
  In FIPS 140 mode      : false
=======================================

BUILD SUCCESSFUL in 2s
23 actionable tasks: 23 up-to-date
┌[kiwish-4.2]-(workplace/harmishlakhani-OpenSearch)-[git:unsafe_bootstrap_read_only_block]-
└> git status
On branch unsafe_bootstrap_read_only_block
Your branch is up to date with 'origin/unsafe_bootstrap_read_only_block'.

nothing to commit, working tree clean

.build();

Boolean applyClusterReadOnlyBlock = applyClusterReadOnlyBlockOption.value(options);
if(Objects.nonNull(applyClusterReadOnlyBlock)) {
Copy link
Member

Choose a reason for hiding this comment

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

I am wondering if the user passes false explicitly, then what should be the behavior. Should we keep the existing block as is (in case it exists on the cluster)? Thoughts?

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 we should entertain what user has given in input, because unsafe-bootstrap should be used consciously and whoever is running the command should know what it will do. Also if cluster block is already present then we hope that user will aware about the same while using this command.

@shwetathareja
Copy link
Member

we might need to raise a backport PR for 1.x after this is merged.

@harmishlakhani
Copy link
Contributor Author

@shwetathareja Yes I will raise backport PR to 1.x after this is merged.
Just one question, shouldn't we merge main branch altogether to 1.x because there will me many PRs which we want to merge to 1.x after they merged to main branch ? Thoughts ?

@saratvemulapalli
Copy link
Member

start gradle check

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 1363ac4
Log 177

Reports 177

Copy link
Member

@saratvemulapalli saratvemulapalli left a comment

Choose a reason for hiding this comment

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

The change looks good to me!

@harmishlakhani if need this change in 1.x, please backport it.

@saratvemulapalli saratvemulapalli merged commit 6732239 into opensearch-project:main May 18, 2021
dblock pushed a commit that referenced this pull request May 20, 2021
…p command #599 (#725)

* apply user defined cluster wide read only block after unsafe bootstrap command

Signed-off-by: Harmish Lakhani <harmish.lakhani@gmail.com>

* Fixed gradle precommit failures

Signed-off-by: Harmish Lakhani <harmish.lakhani@gmail.com>

* remove default as false for read only block to avoid overriding user's existing settings

Signed-off-by: Harmish Lakhani <harmish.lakhani@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unsafe Bootstrap Command with user defined cluster wide read_only block setting
5 participants