Set default SLM retention invocation time (#47604)

This adds a default for the `slm.retention_schedule` setting, setting it
to `0 30 1 * * ?` which is 1:30am every day.

Having retention unset meant that it would never be invoked and clean up
snapshots. We determined it would be better to have a default than never
to be run. When coming to a decision, we weighed the option of an
absolute time (such as 1:30am) versus a periodic invocation (like every
12 hours). In the end we decided on the absolute time because it has
better predictability and consistency than a periodic invocation, which
would rely on when the master node were elected or restarted.

Relates to #43663
This commit is contained in:
Lee Hinman 2019-10-04 14:57:23 -06:00 committed by Lee Hinman
parent f35fcf7204
commit 79376b7219
2 changed files with 9 additions and 1 deletions

View File

@ -1072,6 +1072,11 @@ public class Setting<T> implements ToXContentObject {
return new Setting<>(new SimpleKey(key), null, s -> "", Function.identity(), validator, properties);
}
public static Setting<String> simpleString(String key, String defaultValue, Validator<String> validator, Property... properties) {
validator.validate(defaultValue);
return new Setting<>(new SimpleKey(key), null, s -> defaultValue, Function.identity(), validator, properties);
}
public static Setting<String> simpleString(String key, Setting<String> fallback, Property... properties) {
return simpleString(key, fallback, Function.identity(), properties);
}

View File

@ -38,7 +38,10 @@ public class LifecycleSettings {
public static final Setting<Boolean> SLM_HISTORY_INDEX_ENABLED_SETTING = Setting.boolSetting(SLM_HISTORY_INDEX_ENABLED, true,
Setting.Property.NodeScope);
public static final Setting<String> SLM_RETENTION_SCHEDULE_SETTING = Setting.simpleString(SLM_RETENTION_SCHEDULE, str -> {
public static final Setting<String> SLM_RETENTION_SCHEDULE_SETTING = Setting.simpleString(SLM_RETENTION_SCHEDULE,
// Default to 1:30am every day
"0 30 1 * * ?",
str -> {
try {
if (Strings.hasText(str)) {
// Test that the setting is a valid cron syntax