From 79376b72199350f0efaab7f4c46314e25d268e6b Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 4 Oct 2019 14:57:23 -0600 Subject: [PATCH] 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 --- .../main/java/org/elasticsearch/common/settings/Setting.java | 5 +++++ .../org/elasticsearch/xpack/core/ilm/LifecycleSettings.java | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/common/settings/Setting.java b/server/src/main/java/org/elasticsearch/common/settings/Setting.java index b117993a9c9..dcfd98f8bd6 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/Setting.java +++ b/server/src/main/java/org/elasticsearch/common/settings/Setting.java @@ -1072,6 +1072,11 @@ public class Setting implements ToXContentObject { return new Setting<>(new SimpleKey(key), null, s -> "", Function.identity(), validator, properties); } + public static Setting simpleString(String key, String defaultValue, Validator validator, Property... properties) { + validator.validate(defaultValue); + return new Setting<>(new SimpleKey(key), null, s -> defaultValue, Function.identity(), validator, properties); + } + public static Setting simpleString(String key, Setting fallback, Property... properties) { return simpleString(key, fallback, Function.identity(), properties); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleSettings.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleSettings.java index 5607bfc744e..b2a4c8bcf8d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleSettings.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/LifecycleSettings.java @@ -38,7 +38,10 @@ public class LifecycleSettings { public static final Setting SLM_HISTORY_INDEX_ENABLED_SETTING = Setting.boolSetting(SLM_HISTORY_INDEX_ENABLED, true, Setting.Property.NodeScope); - public static final Setting SLM_RETENTION_SCHEDULE_SETTING = Setting.simpleString(SLM_RETENTION_SCHEDULE, str -> { + public static final Setting 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