Skip to content

Commit 2a67722

Browse files
author
David Roberts
committed
[ML] Disable machine learning on macOS x86_64
As previously advised in #104087, machine learning functionality will no longer be available on macOS x86_64. Machine learning functionality _is_ still available on macOS by using an arm64 machine (Apple silicon). It is also possible to run Elasticsearch with machine learning functionality within a Docker container on macOS x86_64.
1 parent 770fc19 commit 2a67722

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77

88
package org.elasticsearch.xpack.core;
99

10+
import org.apache.logging.log4j.LogManager;
11+
import org.apache.logging.log4j.Logger;
1012
import org.elasticsearch.common.settings.Setting;
1113
import org.elasticsearch.common.settings.Setting.Property;
1214
import org.elasticsearch.common.settings.Settings;
15+
import org.elasticsearch.common.settings.SettingsException;
1316
import org.elasticsearch.common.ssl.SslClientAuthenticationMode;
1417
import org.elasticsearch.common.ssl.SslVerificationMode;
1518
import org.elasticsearch.core.Strings;
19+
import org.elasticsearch.plugins.Platforms;
1620
import org.elasticsearch.transport.RemoteClusterPortSettings;
1721
import org.elasticsearch.xpack.core.security.SecurityField;
1822
import org.elasticsearch.xpack.core.security.authc.support.Hasher;
@@ -26,6 +30,7 @@
2630
import java.util.List;
2731
import java.util.Locale;
2832
import java.util.Map;
33+
import java.util.Set;
2934
import java.util.function.Function;
3035

3136
import javax.crypto.SecretKeyFactory;
@@ -40,6 +45,8 @@
4045
*/
4146
public class XPackSettings {
4247

48+
private static final Logger logger = LogManager.getLogger(XPackSettings.class);
49+
4350
private XPackSettings() {
4451
throw new IllegalStateException("Utility class should not be instantiated");
4552
}
@@ -76,10 +83,21 @@ public Iterator<Setting<?>> settings() {
7683
/** Setting for enabling or disabling graph. Defaults to true. */
7784
public static final Setting<Boolean> GRAPH_ENABLED = Setting.boolSetting("xpack.graph.enabled", true, Setting.Property.NodeScope);
7885

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. */
8089
public static final Setting<Boolean> MACHINE_LEARNING_ENABLED = Setting.boolSetting(
8190
"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+
},
83101
Setting.Property.NodeScope
84102
);
85103

0 commit comments

Comments
 (0)