From 5d760051a9e299c6b128b24b1e4004180c3b089e Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 30 Mar 2020 21:30:46 -0400 Subject: [PATCH] Clarify autoscaling feature flag registration (#54427) This commit clarifies the autoscaling feature flag registration system property. The intention is that this system property is: - unset in snapshot builds - unset, true, or false in release builds - in release builds, unset behaves the same as false - therefore, we only register the enabled flag if the build is a snapshot build, or the build is a release build and the system property is set to true This commit clarifies that intention, and removed a confusion situation where the AUTOSCALING_FEATURE_FLAG_REGISTERED field would be set to false in a snapshot build, even though we were going to register the setting. --- .../org/elasticsearch/xpack/autoscaling/Autoscaling.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java index 6c342c0c85c..2053fc23124 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/Autoscaling.java @@ -33,7 +33,7 @@ import java.util.function.Supplier; */ public class Autoscaling extends Plugin implements ActionPlugin { - private static final boolean AUTOSCALING_FEATURE_FLAG_REGISTERED; + private static final Boolean AUTOSCALING_FEATURE_FLAG_REGISTERED; static { final String property = System.getProperty("es.autoscaling_feature_flag_registered"); @@ -42,8 +42,10 @@ public class Autoscaling extends Plugin implements ActionPlugin { } if ("true".equals(property)) { AUTOSCALING_FEATURE_FLAG_REGISTERED = true; - } else if ("false".equals(property) || property == null) { + } else if ("false".equals(property)) { AUTOSCALING_FEATURE_FLAG_REGISTERED = false; + } else if (property == null) { + AUTOSCALING_FEATURE_FLAG_REGISTERED = null; } else { throw new IllegalArgumentException( "expected es.autoscaling_feature_flag_registered to be unset or [true|false] but was [" + property + "]" @@ -70,7 +72,7 @@ public class Autoscaling extends Plugin implements ActionPlugin { */ @Override public List> getSettings() { - if (isSnapshot() || AUTOSCALING_FEATURE_FLAG_REGISTERED) { + if (isSnapshot() || (AUTOSCALING_FEATURE_FLAG_REGISTERED != null && AUTOSCALING_FEATURE_FLAG_REGISTERED)) { return Collections.singletonList(AUTOSCALING_ENABLED_SETTING); } else { return Collections.emptyList();