Skip to content

Commit 1855782

Browse files
authored
[Rest Api Compatibility] Allow copy_settings flag for resize operations (#75184)
previously removed in #38514, deprecated in 7.x and defaulted to true. With rest api compatibility and when value is true it is ignored and warning is emitted when value is false, an exception is thrown relates #51816
1 parent caa7e16 commit 1855782

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

rest-api-spec/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ tasks.named("yamlRestCompatTest").configure {
9191
'indices.open/10_basic/?wait_for_active_shards=index-setting',
9292
// not fixing this in #70966
9393
'indices.put_template/11_basic_with_types/Put template with empty mappings',
94-
'indices.shrink/30_copy_settings/Copy settings during shrink index',
95-
'indices.split/30_copy_settings/Copy settings during split index',
9694
'mlt/20_docs/Basic mlt query with docs',
9795
'mlt/30_unlike/Basic mlt query with unlike',
9896
'search.aggregation/200_top_hits_metric/top_hits aggregation with sequence numbers',

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestResizeHandler.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import org.elasticsearch.action.admin.indices.shrink.ResizeType;
1313
import org.elasticsearch.action.support.ActiveShardCount;
1414
import org.elasticsearch.client.node.NodeClient;
15+
import org.elasticsearch.common.logging.DeprecationLogger;
16+
import org.elasticsearch.core.Booleans;
17+
import org.elasticsearch.core.RestApiVersion;
1518
import org.elasticsearch.rest.BaseRestHandler;
1619
import org.elasticsearch.rest.RestRequest;
1720
import org.elasticsearch.rest.action.RestToXContentListener;
@@ -23,6 +26,7 @@
2326
import static org.elasticsearch.rest.RestRequest.Method.PUT;
2427

2528
public abstract class RestResizeHandler extends BaseRestHandler {
29+
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestResizeHandler.class);
2630

2731
RestResizeHandler() {
2832
}
@@ -34,6 +38,15 @@ public abstract class RestResizeHandler extends BaseRestHandler {
3438

3539
@Override
3640
public final RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
41+
if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("copy_settings")) {
42+
deprecationLogger.compatibleApiWarning("copy_settings", "parameter [copy_settings] is deprecated and will be removed in 8.0.0");
43+
44+
final String rawCopySettings = request.param("copy_settings");
45+
final boolean copySettings = Booleans.parseBoolean(rawCopySettings);
46+
if (copySettings == false) {
47+
throw new IllegalArgumentException("parameter [copy_settings] can not be explicitly set to [false]");
48+
}
49+
}
3750
final ResizeRequest resizeRequest = new ResizeRequest(request.param("target"), request.param("index"));
3851
resizeRequest.setResizeType(getResizeType());
3952
request.applyContentParser(resizeRequest::fromXContent);

0 commit comments

Comments
 (0)