Skip to content

Commit

Permalink
Add deprecation warning for negative index.unassigned.node_left.delay…
Browse files Browse the repository at this point in the history
…ed_timeout (#26832)

This was deprecated because it becomes forbidden in 7.x as per #26828.
  • Loading branch information
DaveCTurner authored Oct 9, 2017
1 parent b4f5e24 commit 0ba3afe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
import org.elasticsearch.common.joda.Joda;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -47,11 +49,21 @@
*/
public final class UnassignedInfo implements ToXContentFragment, Writeable {

private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(UnassignedInfo.class));

public static final FormatDateTimeFormatter DATE_TIME_FORMATTER = Joda.forPattern("dateOptionalTime");

public static final Setting<TimeValue> INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING =
Setting.timeSetting("index.unassigned.node_left.delayed_timeout", TimeValue.timeValueMinutes(1), Property.Dynamic,
Property.IndexScope);
new Setting<>("index.unassigned.node_left.delayed_timeout", (s) -> TimeValue.timeValueMinutes(1).getStringRep(), (s) -> {
TimeValue parsedValue = TimeValue.parseTimeValue(s, "index.unassigned.node_left.delayed_timeout");
if (parsedValue.getNanos() < 0) {
DEPRECATION_LOGGER.deprecated(
"Negative values for index.unassigned.node_left.delayed_timeout [{}]" +
" are deprecated and should now be set to \"0\".", s);
}
return parsedValue;
}, Property.Dynamic, Property.IndexScope);

/**
* Reason why the shard is in unassigned state.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,11 @@ public void testAllocationStatusSerialization() throws IOException {
assertThat(readStatus, equalTo(allocationStatus));
}
}

public void testNegativeTimeoutDeprecated() {
Settings settings = settings(Version.CURRENT).put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "-1s").build();
assertThat(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.get(settings).seconds(), equalTo(-1L));
assertWarnings("Negative values for index.unassigned.node_left.delayed_timeout [-1s]" +
" are deprecated and should now be set to \"0\".");
}
}

0 comments on commit 0ba3afe

Please sign in to comment.