Skip to content

Commit

Permalink
Deprecates _upgrade API (elastic#47678) (elastic#50484)
Browse files Browse the repository at this point in the history
* Deprecates _upgrade API

Ref elastic#47678

* Move deprecation flags to path section. Add deprecation warning tests for _upgrade API.

Ref elastic#47678
  • Loading branch information
timoninmaxim authored and danhermann committed Nov 5, 2020
1 parent 5e9fd40 commit c77f863
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"indices.get_upgrade":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html",
"description":"The _upgrade API is no longer useful and will be removed."
"description":"DEPRECATED Returns a progress status of current upgrade."
},
"stability":"stable",
"url":{
Expand All @@ -11,7 +11,11 @@
"path":"/_upgrade",
"methods":[
"GET"
]
],
"deprecated":{
"version":"8.0.0",
"description":"The _upgrade API is no longer useful and will be removed. Instead, see _reindex API."
}
},
{
"path":"/{index}/_upgrade",
Expand All @@ -23,6 +27,10 @@
"type":"list",
"description":"A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices"
}
},
"deprecated":{
"version":"8.0.0",
"description":"The _upgrade API is no longer useful and will be removed. Instead, see _reindex API."
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"indices.upgrade":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html",
"description":"The _upgrade API is no longer useful and will be removed."
"description":"DEPRECATED Upgrades to the current version of Lucene."
},
"stability":"stable",
"url":{
Expand All @@ -11,7 +11,11 @@
"path":"/_upgrade",
"methods":[
"POST"
]
],
"deprecated":{
"version":"8.0.0",
"description":"The _upgrade API is no longer useful and will be removed. Instead, see _reindex API."
}
},
{
"path":"/{index}/_upgrade",
Expand All @@ -23,6 +27,10 @@
"type":"list",
"description":"A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices"
}
},
"deprecated":{
"version":"8.0.0",
"description":"The _upgrade API is no longer useful and will be removed. Instead, see _reindex API."
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
"Basic test for upgrade indices":
- skip:
version: " - 7.99.99"
reason: "_upgrade api is deprecated since 8.0.0"
features: ["warnings", "node_selector"]

- do:
indices.create:
Expand All @@ -12,12 +16,21 @@
- do:
indices.upgrade:
index: test_index
warnings:
- "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API."
node_selector:
version: "8.0.0 - "

- match: {upgraded_indices.test_index.oldest_lucene_segment_version: '/(\d\.)+\d/'}
- is_true: upgraded_indices.test_index.upgrade_version

---
"Upgrade indices ignore unavailable":
- skip:
version: " - 7.99.99"
reason: "_upgrade api is deprecated since 8.0.0"
features: ["warnings", "node_selector"]

- do:
indices.create:
index: test_index
Expand All @@ -31,34 +44,58 @@
indices.upgrade:
index: ["does_not_exist", "test_index"]
ignore_unavailable: true
warnings:
- "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API."
node_selector:
version: "8.0.0 - "

- match: {_shards.total: 1}
- is_true: upgraded_indices.test_index.upgrade_version
- is_false: upgraded_indices.does_not_exist

---
"Upgrade indices allow no indices":
- skip:
version: " - 7.99.99"
reason: "_upgrade api is deprecated since 8.0.0"
features: ["warnings", "node_selector"]

- do:
indices.upgrade:
index: test_index
ignore_unavailable: true
allow_no_indices: true
warnings:
- "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API."
node_selector:
version: "8.0.0 - "

- match: {_shards.total: 0}

---
"Upgrade indices disallow no indices":
- skip:
version: " - 7.99.99"
reason: "_upgrade api is deprecated since 8.0.0"
features: ["warnings", "node_selector"]

- do:
catch: missing
indices.upgrade:
index: test_index
ignore_unavailable: true
allow_no_indices: false
warnings:
- "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API."
node_selector:
version: "8.0.0 - "

---
"Upgrade indices disallow unavailable":
- skip:
version: " - 7.99.99"
reason: "_upgrade api is deprecated since 8.0.0"
features: ["warnings", "node_selector"]

- do:
indices.create:
Expand All @@ -69,4 +106,7 @@
indices.upgrade:
index: ["test_index", "does_not_exist"]
ignore_unavailable: false

warnings:
- "The _upgrade API is no longer useful and will be removed. Instead, see _reindex API."
node_selector:
version: "8.0.0 - "
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
"Basic test for upgrade indices < 8.0.0":
- skip:
version: "8.0.0 - "
reason: "_upgrade api has deprecation header since 8.0.0"
features: "node_selector"

- do:
indices.create:
index: test_index
body:
settings:
index:
number_of_replicas: 0

- do:
indices.upgrade:
index: test_index
node_selector:
version: " - 7.99.99"

- match: {upgraded_indices.test_index.oldest_lucene_segment_version: '/(\d\.)+\d/'}
- is_true: upgraded_indices.test_index.upgrade_version

---
"Upgrade indices ignore unavailable < 8.0.0":
- skip:
version: "8.0.0 - "
reason: "_upgrade api has deprecation header since 8.0.0"
features: "node_selector"

- do:
indices.create:
index: test_index
body:
settings:
index:
number_of_shards: 1
number_of_replicas: 0

- do:
indices.upgrade:
index: ["does_not_exist", "test_index"]
ignore_unavailable: true
node_selector:
version: " - 7.99.99"

- match: {_shards.total: 1}
- is_true: upgraded_indices.test_index.upgrade_version
- is_false: upgraded_indices.does_not_exist

---
"Upgrade indices allow no indices < 8.0.0":
- skip:
version: "8.0.0 - "
reason: "_upgrade api has deprecation header since 8.0.0"
features: "node_selector"

- do:
indices.upgrade:
index: test_index
ignore_unavailable: true
allow_no_indices: true
node_selector:
version: " - 7.99.99"

- match: {_shards.total: 0}

---
"Upgrade indices disallow no indices < 8.0.0":
- skip:
version: "8.0.0 - "
reason: "_upgrade api has deprecation header since 8.0.0"
features: "node_selector"

- do:
catch: missing
indices.upgrade:
index: test_index
ignore_unavailable: true
allow_no_indices: false
node_selector:
version: " - 7.99.99"

---
"Upgrade indices disallow unavailable < 8.0.0":
- skip:
version: "8.0.0 - "
reason: "_upgrade api has deprecation header since 8.0.0"
features: "node_selector"

- do:
indices.create:
index: test_index

- do:
catch: missing
indices.upgrade:
index: ["test_index", "does_not_exist"]
ignore_unavailable: false
node_selector:
version: " - 7.99.99"
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@
import org.elasticsearch.rest.action.admin.indices.RestSimulateTemplateAction;
import org.elasticsearch.rest.action.admin.indices.RestSyncedFlushAction;
import org.elasticsearch.rest.action.admin.indices.RestUpdateSettingsAction;
import org.elasticsearch.rest.action.admin.indices.RestUpgradeAction;
import org.elasticsearch.rest.action.admin.indices.RestUpgradeStatusAction;
import org.elasticsearch.rest.action.admin.indices.RestUpgradeActionDeprecated;
import org.elasticsearch.rest.action.admin.indices.RestUpgradeStatusActionDeprecated;
import org.elasticsearch.rest.action.admin.indices.RestValidateQueryAction;
import org.elasticsearch.rest.action.cat.AbstractCatAction;
import org.elasticsearch.rest.action.cat.RestAliasAction;
Expand Down Expand Up @@ -715,8 +715,8 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster) {
registerHandler.accept(new RestFlushAction());
registerHandler.accept(new RestSyncedFlushAction());
registerHandler.accept(new RestForceMergeAction());
registerHandler.accept(new RestUpgradeAction());
registerHandler.accept(new RestUpgradeStatusAction());
registerHandler.accept(new RestUpgradeActionDeprecated());
registerHandler.accept(new RestUpgradeStatusActionDeprecated());
registerHandler.accept(new RestClearIndicesCacheAction());
registerHandler.accept(new RestResolveIndexAction());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@

package org.elasticsearch.rest.action.admin.indices;

import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestToXContentListener;

Expand All @@ -34,7 +37,18 @@
import static java.util.Collections.unmodifiableList;
import static org.elasticsearch.rest.RestRequest.Method.POST;

public class RestUpgradeAction extends BaseRestHandler {
public class RestUpgradeActionDeprecated extends BaseRestHandler {

private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
LogManager.getLogger(RestUpgradeActionDeprecated.class));

public static final String UPGRADE_API_DEPRECATION_MESSAGE =
"The _upgrade API is no longer useful and will be removed. Instead, see _reindex API.";

public RestUpgradeActionDeprecated(RestController controller) {
controller.registerAsDeprecatedHandler(POST, "/_upgrade", this, UPGRADE_API_DEPRECATION_MESSAGE, deprecationLogger);
controller.registerAsDeprecatedHandler(POST, "/{index}/_upgrade", this, UPGRADE_API_DEPRECATION_MESSAGE, deprecationLogger);
}

@Override
public List<Route> routes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@

package org.elasticsearch.rest.action.admin.indices;

import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestToXContentListener;
Expand All @@ -33,14 +35,18 @@
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.action.admin.indices.RestUpgradeActionDeprecated.UPGRADE_API_DEPRECATION_MESSAGE;

public class RestUpgradeStatusAction extends BaseRestHandler {
public class RestUpgradeStatusActionDeprecated extends BaseRestHandler {

@Override
public List<Route> routes() {
return unmodifiableList(asList(
new Route(GET, "/_upgrade"),
new Route(GET, "/{index}/_upgrade")));
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
LogManager.getLogger(RestUpgradeStatusActionDeprecated.class));

public RestUpgradeStatusActionDeprecated(RestController controller) {
controller.registerAsDeprecatedHandler(GET, "/_upgrade", this,
UPGRADE_API_DEPRECATION_MESSAGE, deprecationLogger);
controller.registerAsDeprecatedHandler(GET, "/{index}/_upgrade", this,
UPGRADE_API_DEPRECATION_MESSAGE, deprecationLogger);
}

@Override
Expand Down

0 comments on commit c77f863

Please sign in to comment.