Skip to content

Commit c8e4e9a

Browse files
authored
Remove opendistro settings and endpoints (#3326)
* Remove opendistro settings Signed-off-by: Louis Chu <clingzhi@amazon.com> * Remove OpenDistro endpoints Signed-off-by: Louis Chu <clingzhi@amazon.com> * Fix bwc IT gracefully Signed-off-by: Louis Chu <clingzhi@amazon.com> --------- Signed-off-by: Louis Chu <clingzhi@amazon.com>
1 parent 1b4014d commit c8e4e9a

File tree

15 files changed

+97
-503
lines changed

15 files changed

+97
-503
lines changed

common/src/main/java/org/opensearch/sql/common/setting/LegacySettings.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

docs/user/admin/settings.rst

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,6 @@ Introduction
1616

1717
When OpenSearch bootstraps, SQL plugin will register a few settings in OpenSearch cluster settings. Most of the settings are able to change dynamically so you can control the behavior of SQL plugin without need to bounce your cluster. You can update the settings by sending requests to either ``_cluster/settings`` or ``_plugins/_query/settings`` endpoint, though the examples are sending to the latter.
1818

19-
Breaking Change
20-
===============
21-
opendistro.sql.engine.new.enabled
22-
---------------------------------
23-
The opendistro.sql.engine.new.enabled setting is deprecated and will be removed then. From OpenSearch 1.0, the new engine is always enabled.
24-
25-
opendistro.sql.query.analysis.enabled
26-
-------------------------------------
27-
The opendistro.sql.query.analysis.enabled setting is deprecated and will be removed then. From OpenSearch 1.0, the query analysis in legacy engine is disabled.
28-
29-
opendistro.sql.query.analysis.semantic.suggestion
30-
-------------------------------------------------
31-
The opendistro.sql.query.analysis.semantic.suggestion setting is deprecated and will be removed then. From OpenSearch 1.0, the query analysis suggestion in legacy engine is disabled.
32-
33-
opendistro.sql.query.analysis.semantic.threshold
34-
------------------------------------------------
35-
The opendistro.sql.query.analysis.semantic.threshold setting is deprecated and will be removed then. From OpenSearch 1.0, the query analysis threshold in legacy engine is disabled.
36-
37-
opendistro.sql.query.response.format
38-
------------------------------------
39-
The opendistro.sql.query.response.format setting is deprecated and will be removed then. From OpenSearch 1.0, the query response format is default to JDBC format. `You can change the format by using query parameters<../interfaces/protocol.rst>`_.
40-
41-
opendistro.sql.cursor.enabled
42-
-----------------------------
43-
The opendistro.sql.cursor.enabled setting is deprecated and will be removed then. From OpenSearch 1.0, the cursor feature is enabled by default.
44-
45-
opendistro.sql.cursor.fetch_size
46-
--------------------------------
47-
The opendistro.sql.cursor.fetch_size setting is deprecated and will be removed then. From OpenSearch 1.0, the fetch_size in query body will decide whether create the cursor context. No cursor will be created if the fetch_size = 0.
48-
4919
plugins.sql.enabled
5020
======================
5121

@@ -86,8 +56,6 @@ Result set::
8656
}
8757
}
8858

89-
Note: the legacy settings of ``opendistro.sql.enabled`` is deprecated, it will fallback to the new settings if you request an update with the legacy name.
90-
9159
Example 2
9260
---------
9361

@@ -150,8 +118,6 @@ Result set::
150118
}
151119
}
152120

153-
Note: the legacy settings of ``opendistro.sql.slowlog`` is deprecated, it will fallback to the new settings if you request an update with the legacy name.
154-
155121
plugins.sql.cursor.keep_alive
156122
================================
157123

@@ -194,8 +160,6 @@ Result set::
194160
}
195161
}
196162

197-
Note: the legacy settings of ``opendistro.sql.cursor.keep_alive`` is deprecated, it will fallback to the new settings if you request an update with the legacy name.
198-
199163
plugins.sql.pagination.api
200164
================================
201165

@@ -268,8 +232,6 @@ Result set::
268232
}
269233
}
270234

271-
Note: the legacy settings of ``opendistro.query.size_limit`` is deprecated, it will fallback to the new settings if you request an update with the legacy name.
272-
273235
plugins.query.memory_limit
274236
==========================
275237

@@ -298,9 +260,6 @@ Result set::
298260
"transient": {}
299261
}
300262

301-
Note: the legacy settings of ``opendistro.ppl.query.memory_limit`` is deprecated, it will fallback to the new settings if you request an update with the legacy name.
302-
303-
304263
plugins.sql.delete.enabled
305264
======================
306265

integ-test/src/test/java/org/opensearch/sql/bwc/SQLBackwardsCompatibilityIT.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import static org.opensearch.sql.legacy.TestUtils.createIndexByRestClient;
99
import static org.opensearch.sql.legacy.TestUtils.isIndexExist;
1010
import static org.opensearch.sql.legacy.TestUtils.loadDataByRestClient;
11-
import static org.opensearch.sql.legacy.plugin.RestSqlAction.LEGACY_QUERY_API_ENDPOINT;
1211
import static org.opensearch.sql.legacy.plugin.RestSqlAction.QUERY_API_ENDPOINT;
13-
import static org.opensearch.sql.plugin.rest.RestQuerySettingsAction.LEGACY_SQL_SETTINGS_API_ENDPOINT;
12+
import static org.opensearch.sql.sql.LegacyAPICompatibilityIT.LEGACY_QUERY_API_ENDPOINT;
13+
import static org.opensearch.sql.sql.LegacyAPICompatibilityIT.LEGACY_SQL_SETTINGS_API_ENDPOINT;
1414
import static org.opensearch.sql.util.MatcherUtils.rows;
1515
import static org.opensearch.sql.util.MatcherUtils.schema;
1616
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
@@ -93,21 +93,33 @@ public void testBackwardsCompatibility() throws Exception {
9393
List<Map<String, Object>> plugins = (List<Map<String, Object>>) response.get("plugins");
9494
Set<Object> pluginNames =
9595
plugins.stream().map(map -> map.get("name")).collect(Collectors.toSet());
96+
String version = (String) response.get("version");
97+
98+
boolean isBackwardsIncompatibleVersion = version.startsWith("2.");
99+
96100
switch (CLUSTER_TYPE) {
97101
case OLD:
98102
Assert.assertTrue(pluginNames.contains("opensearch-sql"));
99-
updateLegacySQLSettings();
103+
if (isBackwardsIncompatibleVersion) {
104+
updateLegacySQLSettings();
105+
}
100106
loadIndex(Index.ACCOUNT);
101-
verifySQLQueries(LEGACY_QUERY_API_ENDPOINT);
107+
verifySQLQueries(
108+
isBackwardsIncompatibleVersion ? LEGACY_QUERY_API_ENDPOINT : QUERY_API_ENDPOINT);
102109
break;
103110
case MIXED:
104111
Assert.assertTrue(pluginNames.contains("opensearch-sql"));
105-
verifySQLSettings();
106-
verifySQLQueries(LEGACY_QUERY_API_ENDPOINT);
112+
if (isBackwardsIncompatibleVersion) {
113+
verifySQLSettings();
114+
} else {
115+
// For upgraded nodes, we don't need to verify legacy settings
116+
}
117+
verifySQLQueries(
118+
isBackwardsIncompatibleVersion ? LEGACY_QUERY_API_ENDPOINT : QUERY_API_ENDPOINT);
107119
break;
108120
case UPGRADED:
109121
Assert.assertTrue(pluginNames.contains("opensearch-sql"));
110-
verifySQLSettings();
122+
// For fully upgraded clusters, we don't need to verify legacy settings
111123
verifySQLQueries(QUERY_API_ENDPOINT);
112124
break;
113125
}

integ-test/src/test/java/org/opensearch/sql/legacy/SQLIntegTestCase.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import java.nio.file.Paths;
5454
import java.util.Locale;
5555
import java.util.Map;
56+
import java.util.concurrent.Callable;
5657
import javax.management.MBeanServerInvocationHandler;
5758
import javax.management.ObjectName;
5859
import javax.management.remote.JMXConnector;
@@ -68,6 +69,7 @@
6869
import org.opensearch.client.Request;
6970
import org.opensearch.client.RequestOptions;
7071
import org.opensearch.client.Response;
72+
import org.opensearch.client.ResponseException;
7173
import org.opensearch.client.RestClient;
7274
import org.opensearch.sql.common.setting.Settings;
7375
import org.opensearch.sql.datasource.model.DataSourceMetadata;
@@ -252,6 +254,18 @@ protected Request getSqlCursorCloseRequest(String cursorRequest) {
252254
return sqlRequest;
253255
}
254256

257+
protected void assertBadRequest(Callable<Response> operation) {
258+
try {
259+
operation.call();
260+
Assert.fail("Expected ResponseException was not thrown");
261+
} catch (ResponseException e) {
262+
Assert.assertEquals(400, e.getResponse().getStatusLine().getStatusCode());
263+
Assert.assertEquals("Bad Request", e.getResponse().getStatusLine().getReasonPhrase());
264+
} catch (Exception e) {
265+
Assert.fail("Unexpected exception: " + e.getMessage());
266+
}
267+
}
268+
255269
protected String executeQuery(String query, String requestType) {
256270
return executeQuery(query, requestType, Map.of());
257271
}

integ-test/src/test/java/org/opensearch/sql/ppl/LegacyAPICompatibilityIT.java

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
*/
55
package org.opensearch.sql.ppl;
66

7-
import static org.opensearch.sql.plugin.rest.RestPPLQueryAction.LEGACY_EXPLAIN_API_ENDPOINT;
8-
import static org.opensearch.sql.plugin.rest.RestPPLQueryAction.LEGACY_QUERY_API_ENDPOINT;
9-
import static org.opensearch.sql.plugin.rest.RestPPLStatsAction.PPL_LEGACY_STATS_API_ENDPOINT;
107
import static org.opensearch.sql.plugin.rest.RestQuerySettingsAction.SETTINGS_API_ENDPOINT;
118

129
import java.io.IOException;
@@ -18,49 +15,60 @@
1815

1916
/** For backward compatibility, check if legacy API endpoints are accessible. */
2017
public class LegacyAPICompatibilityIT extends PPLIntegTestCase {
18+
public static final String LEGACY_PPL_API_ENDPOINT = "/_opendistro/_ppl";
19+
public static final String LEGACY_PPL_EXPLAIN_API_ENDPOINT = "/_opendistro/_ppl/_explain";
20+
public static final String LEGACY_PPL_SETTINGS_API_ENDPOINT = "/_opendistro/_ppl/settings";
21+
public static final String LEGACY_PPL_STATS_API_ENDPOINT = "/_opendistro/_ppl/stats";
2122

2223
@Override
2324
public void init() throws IOException {
2425
loadIndex(Index.ACCOUNT);
2526
}
2627

2728
@Test
28-
public void query() throws IOException {
29+
public void query() {
2930
String query = "source=opensearch-sql_test_index_account | where age > 30";
30-
Request request = buildRequest(query, LEGACY_QUERY_API_ENDPOINT);
31-
Response response = client().performRequest(request);
32-
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
31+
Request request = buildRequest(query, LEGACY_PPL_API_ENDPOINT);
32+
assertBadRequest(() -> client().performRequest(request));
3333
}
3434

3535
@Test
36-
public void explain() throws IOException {
36+
public void explain() {
3737
String query = "source=opensearch-sql_test_index_account | where age > 30";
38-
Request request = buildRequest(query, LEGACY_EXPLAIN_API_ENDPOINT);
39-
Response response = client().performRequest(request);
40-
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
38+
Request request = buildRequest(query, LEGACY_PPL_EXPLAIN_API_ENDPOINT);
39+
assertBadRequest(() -> client().performRequest(request));
4140
}
4241

4342
@Test
44-
public void stats() throws IOException {
45-
Request request = new Request("GET", PPL_LEGACY_STATS_API_ENDPOINT);
46-
Response response = client().performRequest(request);
47-
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
43+
public void stats() {
44+
Request request = new Request("GET", LEGACY_PPL_STATS_API_ENDPOINT);
45+
assertBadRequest(() -> client().performRequest(request));
4846
}
4947

5048
@Test
51-
public void legacySettingNewEndpoint() throws IOException {
49+
public void legacyPPLSettingNewEndpoint() {
5250
String requestBody =
5351
"{"
5452
+ " \"persistent\": {"
5553
+ " \"opendistro.ppl.query.memory_limit\": \"80%\""
5654
+ " }"
5755
+ "}";
58-
Response response = updateSetting(SETTINGS_API_ENDPOINT, requestBody);
59-
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
56+
assertBadRequest(() -> updateSetting(SETTINGS_API_ENDPOINT, requestBody));
57+
}
58+
59+
@Test
60+
public void newPPLSettingsLegacyEndpoint() {
61+
String requestBody =
62+
"{"
63+
+ " \"persistent\": {"
64+
+ " \"plugins.ppl.query.memory_limit\": \"90%\""
65+
+ " }"
66+
+ "}";
67+
assertBadRequest(() -> updateSetting(LEGACY_PPL_SETTINGS_API_ENDPOINT, requestBody));
6068
}
6169

6270
@Test
63-
public void newSettingNewEndpoint() throws IOException {
71+
public void newPPLSettingNewEndpoint() throws IOException {
6472
String requestBody =
6573
"{" + " \"persistent\": {" + " \"plugins.query.size_limit\": \"100\"" + " }" + "}";
6674
Response response = updateSetting(SETTINGS_API_ENDPOINT, requestBody);

0 commit comments

Comments
 (0)