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

deprecation info API: negative index.unassigned.node_left.delayed_timeout #36454

Merged
merged 4 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ private DeprecationChecks() {
Collections.unmodifiableList(Arrays.asList(
IndexDeprecationChecks::oldIndicesCheck,
IndexDeprecationChecks::delimitedPayloadFilterCheck,
IndexDeprecationChecks::indexNameCheck
IndexDeprecationChecks::indexNameCheck,
IndexDeprecationChecks::nodeLeftDelayedTimeCheck
));

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.analysis.AnalysisRegistry;
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;

Expand Down Expand Up @@ -116,4 +119,20 @@ static DeprecationIssue indexNameCheck(IndexMetaData indexMetaData) {
}
return null;
}

static DeprecationIssue nodeLeftDelayedTimeCheck(IndexMetaData indexMetaData) {
String setting = UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey();
String value = indexMetaData.getSettings().get(setting);
if (Strings.isNullOrEmpty(value) == false) {
TimeValue parsedValue = TimeValue.parseTimeValue(value, setting);
if (parsedValue.getNanos() < 0) {
return new DeprecationIssue(DeprecationIssue.Level.WARNING,
"Negative values for index.unassigned.node_left.delayed_timeout are deprecated and should be set to 0",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
"#_literal_index_unassigned_node_left_delayed_timeout_literal_may_no_longer_be_negative",
"The index [" + indexMetaData.getIndex().getName() + "] is set to " + value);
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
Expand Down Expand Up @@ -76,4 +77,31 @@ public void testIndexNameCheck(){
List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex));
assertTrue(noIssues.isEmpty());
}

public void testNodeLeftDelayedTimeCheck() {
String negativeTimeValue = "-" + randomPositiveTimeValue();
String indexName = randomAlphaOfLengthBetween(0, 10);

final IndexMetaData badIndex = IndexMetaData.builder(indexName)
.settings(settings(Version.CURRENT).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), negativeTimeValue))
.numberOfShards(randomIntBetween(1, 100))
.numberOfReplicas(randomIntBetween(1, 15))
.build();
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.WARNING,
"Negative values for index.unassigned.node_left.delayed_timeout are deprecated and should be set to 0",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
"#_literal_index_unassigned_node_left_delayed_timeout_literal_may_no_longer_be_negative",
"The index [" + indexName + "] is set to " + negativeTimeValue);

List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(badIndex));
assertEquals(singletonList(expected), issues);

final IndexMetaData goodIndex = IndexMetaData.builder(indexName)
.settings(settings(Version.CURRENT))
.numberOfShards(randomIntBetween(1, 100))
.numberOfReplicas(randomIntBetween(1, 15))
.build();
List<DeprecationIssue> noIssues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(goodIndex));
assertTrue(noIssues.isEmpty());
}
}