-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[ML] Disable CPS for Dataframes #136716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Disable CPS for Dataframes #136716
Changes from 1 commit
345b57c
bba12ed
c928dcf
c2460f6
95b8da2
fc812d5
6c3f288
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.ml.integration; | ||
|
|
||
| import org.elasticsearch.common.ValidationException; | ||
| import org.elasticsearch.common.settings.Setting; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.index.query.QueryBuilders; | ||
| import org.elasticsearch.plugins.ClusterPlugin; | ||
| import org.elasticsearch.plugins.Plugin; | ||
| import org.elasticsearch.xpack.core.ml.action.PutDataFrameAnalyticsAction; | ||
| import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsConfig; | ||
| import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsDest; | ||
| import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsSource; | ||
| import org.elasticsearch.xpack.core.ml.dataframe.analyses.BoostedTreeParams; | ||
| import org.elasticsearch.xpack.core.ml.dataframe.analyses.Classification; | ||
| import org.elasticsearch.xpack.core.ml.utils.QueryProvider; | ||
| import org.elasticsearch.xpack.ml.MlSingleNodeTestCase; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import static org.hamcrest.Matchers.containsString; | ||
|
|
||
| public class DataframeCpsIT extends MlSingleNodeTestCase { | ||
| @Override | ||
| protected Settings nodeSettings() { | ||
| return Settings.builder().put(super.nodeSettings()).put("serverless.cross_project.enabled", "true").build(); | ||
| } | ||
|
|
||
| @Override | ||
| protected Collection<Class<? extends Plugin>> getPlugins() { | ||
| return Stream.concat(super.getPlugins().stream(), Stream.of(CpsPlugin.class)).toList(); | ||
| } | ||
|
|
||
| public void testCrossProjectFailsForDataFrameAnalytics() throws IOException { | ||
| var id = "test-cross-project-fails"; | ||
| var sourceIndex = "project1:" + id + "_source_index"; | ||
| var destIndex = id + "_results"; | ||
|
|
||
| var config = new DataFrameAnalyticsConfig.Builder().setId(id) | ||
| .setSource( | ||
| new DataFrameAnalyticsSource( | ||
| new String[] { sourceIndex }, | ||
| QueryProvider.fromParsedQuery(QueryBuilders.matchAllQuery()), | ||
| null, | ||
| Collections.emptyMap() | ||
| ) | ||
| ) | ||
| .setDest(new DataFrameAnalyticsDest(destIndex, null)) | ||
| .setAnalysis( | ||
| new Classification( | ||
| "keyword-field", | ||
| BoostedTreeParams.builder().setNumTopFeatureImportanceValues(1).build(), | ||
| null, | ||
| null, | ||
| null, | ||
| null, | ||
| null, | ||
| null, | ||
| null | ||
| ) | ||
| ) | ||
| .build(); | ||
|
|
||
| var request = new PutDataFrameAnalyticsAction.Request(config); | ||
| var response = client().execute(PutDataFrameAnalyticsAction.INSTANCE, request); | ||
| var validationException = assertThrows(ValidationException.class, response::actionGet); | ||
| assertThat(validationException.getMessage(), containsString("cross-project indices are not supported")); | ||
| } | ||
|
|
||
| public static class CpsPlugin extends Plugin implements ClusterPlugin { | ||
| public List<Setting<?>> getSettings() { | ||
| return List.of(Setting.simpleString("serverless.cross_project.enabled", Setting.Property.NodeScope)); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| import org.elasticsearch.license.LicenseUtils; | ||
| import org.elasticsearch.license.RemoteClusterLicenseChecker; | ||
| import org.elasticsearch.license.XPackLicenseState; | ||
| import org.elasticsearch.search.crossproject.CrossProjectModeDecider; | ||
| import org.elasticsearch.tasks.Task; | ||
| import org.elasticsearch.threadpool.ThreadPool; | ||
| import org.elasticsearch.transport.TransportService; | ||
|
|
@@ -118,6 +119,7 @@ public TransportPutDataFrameAnalyticsAction( | |
| transportService.getRemoteClusterService(), | ||
| null, | ||
| null, | ||
| new CrossProjectModeDecider(clusterService.getSettings()).crossProjectEnabled(), | ||
|
||
| clusterService.getNodeName(), | ||
| License.OperationMode.PLATINUM.description() | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main bit of changed logic - if we're in an environment that supports cross-project, then we are also in an environment that does not support cross-cluster, so we display the appropriate error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prwhelan do we really need to have two separate validation failures? Why not just one that says "remote source and cross-project indices are not supported". Seems like an unnecessary complication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with that, though this code will come back for the transform check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prwhelan right, transforms only support remote indices, not cps. I think thats fine.