| 
7 | 7 | 
 
  | 
8 | 8 | package org.elasticsearch.xpack.core;  | 
9 | 9 | 
 
  | 
 | 10 | +import org.apache.logging.log4j.LogManager;  | 
 | 11 | +import org.apache.logging.log4j.Logger;  | 
10 | 12 | import org.elasticsearch.common.settings.Setting;  | 
11 | 13 | import org.elasticsearch.common.settings.Setting.Property;  | 
12 | 14 | import org.elasticsearch.common.settings.Settings;  | 
 | 15 | +import org.elasticsearch.common.settings.SettingsException;  | 
13 | 16 | import org.elasticsearch.common.ssl.SslClientAuthenticationMode;  | 
14 | 17 | import org.elasticsearch.common.ssl.SslVerificationMode;  | 
15 | 18 | import org.elasticsearch.core.Strings;  | 
 | 19 | +import org.elasticsearch.plugins.Platforms;  | 
16 | 20 | import org.elasticsearch.transport.RemoteClusterPortSettings;  | 
17 | 21 | import org.elasticsearch.xpack.core.security.SecurityField;  | 
18 | 22 | import org.elasticsearch.xpack.core.security.authc.support.Hasher;  | 
 | 
26 | 30 | import java.util.List;  | 
27 | 31 | import java.util.Locale;  | 
28 | 32 | import java.util.Map;  | 
 | 33 | +import java.util.Set;  | 
29 | 34 | import java.util.function.Function;  | 
30 | 35 | 
 
  | 
31 | 36 | import javax.crypto.SecretKeyFactory;  | 
 | 
40 | 45 |  */  | 
41 | 46 | public class XPackSettings {  | 
42 | 47 | 
 
  | 
 | 48 | +    private static final Logger logger = LogManager.getLogger(XPackSettings.class);  | 
 | 49 | + | 
43 | 50 |     private XPackSettings() {  | 
44 | 51 |         throw new IllegalStateException("Utility class should not be instantiated");  | 
45 | 52 |     }  | 
@@ -76,10 +83,21 @@ public Iterator<Setting<?>> settings() {  | 
76 | 83 |     /** Setting for enabling or disabling graph. Defaults to true. */  | 
77 | 84 |     public static final Setting<Boolean> GRAPH_ENABLED = Setting.boolSetting("xpack.graph.enabled", true, Setting.Property.NodeScope);  | 
78 | 85 | 
 
  | 
79 |  | -    /** Setting for enabling or disabling machine learning. Defaults to true. */  | 
 | 86 | +    public static final Set<String> ML_NATIVE_CODE_PLATFORMS = Set.of("darwin-aarch64", "linux-aarch64", "linux-x86_64", "windows-x86_64");  | 
 | 87 | + | 
 | 88 | +    /** Setting for enabling or disabling machine learning. Defaults to true on platforms that have the ML native code available. */  | 
80 | 89 |     public static final Setting<Boolean> MACHINE_LEARNING_ENABLED = Setting.boolSetting(  | 
81 | 90 |         "xpack.ml.enabled",  | 
82 |  | -        true,  | 
 | 91 | +        ML_NATIVE_CODE_PLATFORMS.contains(Platforms.PLATFORM_NAME),  | 
 | 92 | +        enabled -> {  | 
 | 93 | +            if (enabled && ML_NATIVE_CODE_PLATFORMS.contains(Platforms.PLATFORM_NAME) == false) {  | 
 | 94 | +                SettingsException e = new SettingsException("xpack.ml.enabled cannot be set to [true] on [{}]", Platforms.PLATFORM_NAME);  | 
 | 95 | +                // The exception doesn't get logged nicely on the console because it's thrown during initial plugin loading,  | 
 | 96 | +                // so log separately here to make absolutely clear what happened  | 
 | 97 | +                logger.fatal(e.getMessage());  | 
 | 98 | +                throw e;  | 
 | 99 | +            }  | 
 | 100 | +        },  | 
83 | 101 |         Setting.Property.NodeScope  | 
84 | 102 |     );  | 
85 | 103 | 
 
  | 
 | 
0 commit comments