-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Deprecate setting 'cluster.no_master_block' and introduce the alternative setting 'cluster.no_cluster_manager_block' #2453
Changes from 4 commits
69c0835
22907d9
8470749
301edbc
36e230a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,14 +76,24 @@ public class NoMasterBlockService { | |
"write", | ||
NoMasterBlockService::parseNoMasterBlock, | ||
Property.Dynamic, | ||
Property.NodeScope, | ||
Property.Deprecated | ||
); | ||
// The setting below is going to replace the above. | ||
// To keep backwards compatibility, the old usage is remained, and it's also used as the fallback for the new usage. | ||
public static final Setting<ClusterBlock> NO_CLUSTER_MANAGER_BLOCK_SETTING = new Setting<>( | ||
"cluster.no_cluster_manager_block", | ||
NO_MASTER_BLOCK_SETTING, | ||
NoMasterBlockService::parseNoMasterBlock, | ||
Property.Dynamic, | ||
Property.NodeScope | ||
); | ||
|
||
private volatile ClusterBlock noMasterBlock; | ||
|
||
public NoMasterBlockService(Settings settings, ClusterSettings clusterSettings) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When are we targeting updating the language in places like these? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the methods that published to maven as Java APIs, I think there are 2 paths.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As @mch2 noted below, I was referring to internal class and method names that include the master language. I agree that incorporating those changes would make the diff rather large. Can you create an issue to track this renaming, if there isn't one already? This can be implemented/committed independent of #1684 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the |
||
this.noMasterBlock = NO_MASTER_BLOCK_SETTING.get(settings); | ||
clusterSettings.addSettingsUpdateConsumer(NO_MASTER_BLOCK_SETTING, this::setNoMasterBlock); | ||
this.noMasterBlock = NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings); | ||
clusterSettings.addSettingsUpdateConsumer(NO_CLUSTER_MANAGER_BLOCK_SETTING, this::setNoMasterBlock); | ||
} | ||
|
||
private static ClusterBlock parseNoMasterBlock(String value) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.cluster.coordination; | ||
|
||
import org.opensearch.common.settings.ClusterSettings; | ||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.test.OpenSearchTestCase; | ||
|
||
import java.util.Arrays; | ||
import java.util.Set; | ||
|
||
/** | ||
* A unit test to validate the former name of the setting 'cluster.no_cluster_manager_block' still take effect, | ||
* after it is deprecated, so that the backwards compatibility is maintained. | ||
* The test can be removed along with removing support of the deprecated setting. | ||
*/ | ||
public class NoMasterBlockServiceRenamedSettingTests extends OpenSearchTestCase { | ||
|
||
/** | ||
* Validate the both settings are known and supported. | ||
*/ | ||
public void testReindexSettingsExist() { | ||
Set<Setting<?>> settings = ClusterSettings.BUILT_IN_CLUSTER_SETTINGS; | ||
assertTrue( | ||
"Both 'cluster.no_cluster_manager_block' and its predecessor should be supported built-in settings.", | ||
settings.containsAll( | ||
Arrays.asList(NoMasterBlockService.NO_MASTER_BLOCK_SETTING, NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING) | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Validate the default value of the both settings is the same. | ||
*/ | ||
public void testSettingFallback() { | ||
assertEquals( | ||
NoMasterBlockService.NO_MASTER_BLOCK_SETTING.get(Settings.EMPTY), | ||
NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(Settings.EMPTY) | ||
|
||
); | ||
} | ||
|
||
/** | ||
* Validate the new setting can be configured correctly, and it doesn't impact the old setting. | ||
*/ | ||
public void testSettingGetValue() { | ||
Settings settings = Settings.builder().put("cluster.no_cluster_manager_block", "all").build(); | ||
assertEquals(NoMasterBlockService.NO_MASTER_BLOCK_ALL, NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings)); | ||
assertEquals( | ||
NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getDefault(Settings.EMPTY), | ||
NoMasterBlockService.NO_MASTER_BLOCK_SETTING.get(settings) | ||
); | ||
} | ||
|
||
/** | ||
* Validate the value of the old setting will be applied to the new setting, if the new setting is not configured. | ||
*/ | ||
public void testSettingGetValueWithFallback() { | ||
Settings settings = Settings.builder().put("cluster.no_master_block", "metadata_write").build(); | ||
assertEquals( | ||
NoMasterBlockService.NO_MASTER_BLOCK_METADATA_WRITES, | ||
NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings) | ||
); | ||
assertSettingDeprecationsAndWarnings(new Setting<?>[] { NoMasterBlockService.NO_MASTER_BLOCK_SETTING }); | ||
} | ||
|
||
/** | ||
* Validate the value of the old setting will be ignored, if the new setting is configured. | ||
*/ | ||
public void testSettingGetValueWhenBothAreConfigured() { | ||
Settings settings = Settings.builder() | ||
.put("cluster.no_cluster_manager_block", "all") | ||
.put("cluster.no_master_block", "metadata_write") | ||
.build(); | ||
assertEquals(NoMasterBlockService.NO_MASTER_BLOCK_ALL, NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings)); | ||
assertEquals(NoMasterBlockService.NO_MASTER_BLOCK_METADATA_WRITES, NoMasterBlockService.NO_MASTER_BLOCK_SETTING.get(settings)); | ||
assertSettingDeprecationsAndWarnings(new Setting<?>[] { NoMasterBlockService.NO_MASTER_BLOCK_SETTING }); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something preventing us from updating NoMasterBlockService as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry just saw your response to kartg with the same question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mch2 thanks for your review! Actually there is nothing blocked. The main reason not to change the class or method name in this PR is to control the size of the code changes in a single PR. Another reason is there are too many class or method that have been published to maven needs renaming, and I didn't target in version 2.0.0 for them.