Skip to content

Commit e54c7cf

Browse files
David Robertsedsavagevaleriy42
authored
[ML] Disable machine learning on macOS x86_64 (#104125)
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. This PR should be merged to main after the branch is split for the last minor release scheduled for before December 2024. For example, suppose 8.17.0 is scheduled for release in November 2024 and 8.18.0 is scheduled for release in January 2025. Then this PR should be merged to main after the 8.17 branch is split. One this PR is merged a followup PR should be opened against the ml-cpp repo to remove the build system for darwin-x86_64. It has been confirmed that with this change in place the Elasticsearch build system works with an ml-cpp bundle that does not contain a platform/darwin-x86_64 directory. It still produces an Elasticsearch build that will run providing xpack.ml.enabled is not explicitly set to true. After the build system for darwin-x86_64 has been removed from the ml-cpp repo, we will be able to do another PyTorch upgrade without having to worry about tweaking the build system to work on Intel macOS. --------- Co-authored-by: Ed Savage <[email protected]> Co-authored-by: Valeriy Khakhutskyy <[email protected]>
1 parent c35777a commit e54c7cf

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

docs/changelog/104125.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pr: 104125
2+
summary: Disable machine learning on macOS x86_64
3+
area: Machine Learning
4+
type: breaking
5+
issues: []
6+
breaking:
7+
title: Disable machine learning on macOS x86_64
8+
area: Packaging
9+
details: The machine learning plugin is permanently disabled on macOS x86_64.
10+
For the last three years Apple has been selling hardware based on the arm64
11+
architecture, and support will increasingly focus on this architecture in
12+
the future. Changes to upstream dependencies of Elastic's machine learning
13+
functionality have made it unviable for Elastic to continue to build machine
14+
learning on macOS x86_64.
15+
impact: To continue to use machine learning functionality on macOS please switch to
16+
an arm64 machine (Apple silicon). Alternatively, it will still be possible to run
17+
Elasticsearch with machine learning enabled in a Docker container on macOS x86_64.
18+
notable: false

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

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.elasticsearch.cluster.service.ClusterService;
3333
import org.elasticsearch.common.breaker.CircuitBreaker;
3434
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
35-
import org.elasticsearch.common.logging.DeprecationCategory;
3635
import org.elasticsearch.common.logging.DeprecationLogger;
3736
import org.elasticsearch.common.settings.ClusterSettings;
3837
import org.elasticsearch.common.settings.IndexScopedSettings;
@@ -69,7 +68,6 @@
6968
import org.elasticsearch.plugins.ExtensiblePlugin;
7069
import org.elasticsearch.plugins.IngestPlugin;
7170
import org.elasticsearch.plugins.PersistentTaskPlugin;
72-
import org.elasticsearch.plugins.Platforms;
7371
import org.elasticsearch.plugins.Plugin;
7472
import org.elasticsearch.plugins.SearchPlugin;
7573
import org.elasticsearch.plugins.ShutdownAwarePlugin;
@@ -931,15 +929,6 @@ public Collection<?> createComponents(PluginServices services) {
931929
return List.of(new JobManagerHolder(), new MachineLearningExtensionHolder());
932930
}
933931

934-
if ("darwin-x86_64".equals(Platforms.PLATFORM_NAME)) {
935-
String msg = "The machine learning plugin will be permanently disabled on macOS x86_64 in new minor versions released "
936-
+ "from December 2024 onwards. To continue to use machine learning functionality on macOS please switch to an arm64 "
937-
+ "machine (Apple silicon). Alternatively, it will still be possible to run Elasticsearch with machine learning "
938-
+ "enabled in a Docker container on macOS x86_64.";
939-
logger.warn(msg);
940-
deprecationLogger.warn(DeprecationCategory.PLUGINS, "ml-darwin-x86_64", msg);
941-
}
942-
943932
machineLearningExtension.get().configure(environment.settings());
944933

945934
this.mlUpgradeModeActionFilter.set(new MlUpgradeModeActionFilter(clusterService));

0 commit comments

Comments
 (0)