Skip to content

Deprecate Migration Assistance and Upgrade APIs #40072

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

Merged
merged 9 commits into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@

package org.elasticsearch.client;

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.migration.DeprecationInfoRequest;
import org.elasticsearch.client.migration.DeprecationInfoResponse;
import org.elasticsearch.client.migration.IndexUpgradeInfoRequest;
import org.elasticsearch.client.migration.IndexUpgradeInfoResponse;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.migration.IndexUpgradeRequest;
import org.elasticsearch.client.tasks.TaskSubmissionResponse;
import org.elasticsearch.index.reindex.BulkByScrollResponse;
import org.elasticsearch.client.migration.IndexUpgradeRequest;


import java.io.IOException;
import java.util.Collections;
Expand All @@ -54,22 +53,49 @@ public final class MigrationClient {
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
* @deprecated Use {@link MigrationClient#getDeprecationInfo} instead
*/
@Deprecated
public IndexUpgradeInfoResponse getAssistance(IndexUpgradeInfoRequest request, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(request, MigrationRequestConverters::getMigrationAssistance, options,
IndexUpgradeInfoResponse::fromXContent, Collections.emptySet());
}

/**
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
* @deprecated The Migration Upgrade API is deprecated, use the Kibana Upgrade Assistant or Reindex API instead.
*/
@Deprecated
public BulkByScrollResponse upgrade(IndexUpgradeRequest request, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(request, MigrationRequestConverters::migrate, options,
BulkByScrollResponse::fromXContent, Collections.emptySet());
}

/**
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
* @deprecated The Migration Upgrade API is deprecated, use the Kibana Upgrade Assistant or Reindex API instead.
*/
@Deprecated
public TaskSubmissionResponse submitUpgradeTask(IndexUpgradeRequest request, RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(request, MigrationRequestConverters::submitMigrateTask, options,
TaskSubmissionResponse::fromXContent, Collections.emptySet());
}

/**
*
* @param request the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @deprecated The Migration Upgrade API is deprecated, use the Kibana Upgrade Assistant or Reindex API instead.
*/
@Deprecated
public void upgradeAsync(IndexUpgradeRequest request, RequestOptions options, ActionListener<BulkByScrollResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, MigrationRequestConverters::migrate, options,
BulkByScrollResponse::fromXContent, listener, Collections.emptySet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
/**
* A request for retrieving upgrade information
* Part of Migration API
* @deprecated Use the Deprecation Info API, which uses {@link DeprecationInfoRequest} instead.
*/
@Deprecated
public class IndexUpgradeInfoRequest extends TimedRequest implements IndicesRequest.Replaceable {

private String[] indices = Strings.EMPTY_ARRAY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@

/**
* Response object that contains information about indices to be upgraded
* @deprecated Use the Deprecation Info API which returns {@link DeprecationInfoResponse} instead.
*/
@Deprecated
public class IndexUpgradeInfoResponse {

private static final ParseField INDICES = new ParseField("indices");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
/**
* A request for performing Upgrade on Index
* Part of Migration API
* @deprecated The Migration Upgrade API is deprecated, use the Kibana Upgrade Assistant or Reindex API instead.
*/
@Deprecated
public class IndexUpgradeRequest implements Validatable {

private String index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

/**
* Indicates the type of the upgrade required for the index
* @deprecated The Migration Assistance API is deprecated, use the Deprecation Info API instead.
*/
@Deprecated
public enum UpgradeActionRequired {
NOT_APPLICABLE, // Indicates that the check is not applicable to this index type, the next check will be performed
UP_TO_DATE, // Indicates that the check finds this index to be up to date - no additional checks are required
Expand Down
9 changes: 7 additions & 2 deletions docs/reference/migration/apis/assistance.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
<titleabbrev>Migration assistance</titleabbrev>
++++

The Migration Assistance API analyzes existing indices in the cluster and
returns the information about indices that require some changes before the
IMPORTANT: The Migration Assistance API is deprecated, use the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone uses this API in 6.7, will it return correct information ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a tweak to this to make sure the behavior aligns, but as of this PR, if used in 6.7, this API will correctly identify which indices need to be reindexed, including internal indices. It will only say that indices need to be "upgraded" if they were not properly upgraded before upgrading the cluster to 6 and need to be fixed using the Migration Upgrade API.

<<migration-api-deprecation,deprecation info API>> instead, which provides more
complete and detailed information about actions necessary prior to upgrade.

deprecated[6.7, Use the <<migration-api-deprecation,Deprecation Info API>>
instead.] The migration assistance API analyzes existing indices in the cluster
and returns the information about indices that require some changes before the
cluster can be upgraded to the next major version.

[float]
Expand Down
10 changes: 8 additions & 2 deletions docs/reference/migration/apis/upgrade.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
<titleabbrev>Migration upgrade</titleabbrev>
++++

The Migration Upgrade API performs the upgrade of internal indices to make them
compatible with the next major version.
IMPORTANT: To prepare a cluster for an upgrade to Elasticsearch version 7, use
the {kibana-ref}/upgrade-assistant.html[{kib} Upgrade Assistant] or
<<reindex-upgrade,reindex manually>> before upgrading.

deprecated[6.7, Use the {kibana-ref}/upgrade-assistant.html[{kib} Upgrade
Assistant] or <<reindex-upgrade,reindex manually>> before upgrading.] The
migration upgrade API performs the upgrade of internal indices to make them
compatible with version 6 of Elasticsearch.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone uses this API in 6.7 will it work correctly ?

Copy link
Contributor Author

@gwbrown gwbrown Mar 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a tweak to this to make sure the behavior aligns, but as of this PR, if used in 6.7, the Upgrade API will only upgrade indices that need to be upgraded from their 5.x format (i.e. they were not upgraded before upgrading the cluster). Otherwise, it will just say that the index needs to be reindexed.

That is, if the .watches-6 index was created and upgraded in 5.x, the Upgrade API will refuse to upgrade it and just say that it needs to be reindexed.


[float]
==== Request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ setup:

---
"Upgrade info - all":
- skip:
version: " - 6.6.99"
reason: Deprecated in 6.7.0, will not issue warnings before 6.7.0
features: "warnings"
- do:
warnings:
- "[GET _xpack/migration/assistance/{index}] is deprecated. Use [GET _xpack/migration/deprecations?index={index}] instead."
xpack.migration.get_assistance: { index: _all }

- length: { indices: 0 }
Expand All @@ -39,8 +45,13 @@ setup:

---
"Upgrade test - wait_for_completion:false":

- skip:
version: " - 6.6.99"
reason: Deprecated in 6.7.0, will not issue warnings before 6.7.0
features: "warnings"
- do:
warnings:
- "[_xpack/migration/upgrade] is deprecated. Use the Kibana Upgrade Assistant or the Reindex API instead."
xpack.migration.upgrade:
index: test1
wait_for_completion: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private UpgradeActionRequired upgradeInfo(IndexMetaData indexMetaData, String in
}
}
// Catch all check for all indices that didn't match the specific checks
if (indexMetaData.getCreationVersion().before(Version.V_5_0_0)) {
if (indexMetaData.getCreationVersion().before(Version.V_6_0_0)) {
return UpgradeActionRequired.REINDEX;
} else {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@
import org.elasticsearch.xpack.core.template.TemplateUtils;
import org.elasticsearch.xpack.core.upgrade.actions.IndexUpgradeAction;
import org.elasticsearch.xpack.core.upgrade.actions.IndexUpgradeInfoAction;
import org.elasticsearch.xpack.upgrade.actions.TransportIndexUpgradeAction;
import org.elasticsearch.xpack.upgrade.actions.TransportIndexUpgradeInfoAction;
import org.elasticsearch.xpack.upgrade.rest.RestIndexUpgradeAction;
import org.elasticsearch.xpack.upgrade.rest.RestIndexUpgradeInfoAction;
import org.elasticsearch.xpack.core.watcher.WatcherState;
import org.elasticsearch.xpack.core.watcher.client.WatcherClient;
import org.elasticsearch.xpack.core.watcher.execution.TriggeredWatchStoreField;
import org.elasticsearch.xpack.core.watcher.support.WatcherIndexTemplateRegistryField;
import org.elasticsearch.xpack.core.watcher.transport.actions.service.WatcherServiceRequest;
import org.elasticsearch.xpack.core.watcher.transport.actions.stats.WatcherStatsResponse;
import org.elasticsearch.xpack.upgrade.actions.TransportIndexUpgradeAction;
import org.elasticsearch.xpack.upgrade.actions.TransportIndexUpgradeInfoAction;
import org.elasticsearch.xpack.upgrade.rest.RestIndexUpgradeAction;
import org.elasticsearch.xpack.upgrade.rest.RestIndexUpgradeInfoAction;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
Expand Down Expand Up @@ -152,7 +152,7 @@ static BiFunction<Client, ClusterService, IndexUpgradeCheck> getSecurityUpgradeC
|| indexMetaData.getAliases().containsKey(".security")) {

if (checkInternalIndexFormat(indexMetaData)) {
return UpgradeActionRequired.UP_TO_DATE;
return checkIndexNeedsReindex(indexMetaData);
} else {
return UpgradeActionRequired.UPGRADE;
}
Expand Down Expand Up @@ -257,7 +257,7 @@ static BiFunction<Client, ClusterService, IndexUpgradeCheck> getWatchesIndexUpgr
indexMetaData -> {
if (indexOrAliasExists(indexMetaData, ".watches")) {
if (checkInternalIndexFormat(indexMetaData)) {
return UpgradeActionRequired.UP_TO_DATE;
return checkIndexNeedsReindex(indexMetaData);
} else {
return UpgradeActionRequired.UPGRADE;
}
Expand Down Expand Up @@ -285,7 +285,7 @@ static BiFunction<Client, ClusterService, IndexUpgradeCheck> getTriggeredWatches
indexMetaData -> {
if (indexOrAliasExists(indexMetaData, TriggeredWatchStoreField.INDEX_NAME)) {
if (checkInternalIndexFormat(indexMetaData)) {
return UpgradeActionRequired.UP_TO_DATE;
return checkIndexNeedsReindex(indexMetaData);
} else {
return UpgradeActionRequired.UPGRADE;
}
Expand All @@ -302,6 +302,14 @@ static BiFunction<Client, ClusterService, IndexUpgradeCheck> getTriggeredWatches
};
}

private static UpgradeActionRequired checkIndexNeedsReindex(IndexMetaData indexMetaData) {
if (indexMetaData.getCreationVersion().before(Version.V_6_0_0)) {
return UpgradeActionRequired.REINDEX;
} else {
return UpgradeActionRequired.UP_TO_DATE;
}
}

private static boolean indexOrAliasExists(IndexMetaData indexMetaData, String name) {
return name.equals(indexMetaData.getIndex().getName()) || indexMetaData.getAliases().containsKey(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
*/
package org.elasticsearch.xpack.upgrade.rest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.bulk.BulkItemResponse;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
Expand All @@ -32,9 +35,14 @@
import java.util.Map;

public class RestIndexUpgradeAction extends BaseRestHandler {
private static final Logger logger = LogManager.getLogger(RestIndexUpgradeAction.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public RestIndexUpgradeAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(RestRequest.Method.POST, "_xpack/migration/upgrade/{index}", this);
controller.registerAsDeprecatedHandler(RestRequest.Method.POST, "_xpack/migration/upgrade/{index}", this,
"[_xpack/migration/upgrade] is deprecated. Use the Kibana Upgrade Assistant or the Reindex API instead.",
deprecationLogger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
*/
package org.elasticsearch.xpack.upgrade.rest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
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.common.settings.Settings;
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
import org.elasticsearch.rest.BaseRestHandler;
Expand All @@ -19,11 +22,17 @@
import java.io.IOException;

public class RestIndexUpgradeInfoAction extends BaseRestHandler {
private static final Logger logger = LogManager.getLogger(RestIndexUpgradeInfoAction.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public RestIndexUpgradeInfoAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(RestRequest.Method.GET, "/_xpack/migration/assistance", this);
controller.registerHandler(RestRequest.Method.GET, "/_xpack/migration/assistance/{index}", this);
controller.registerAsDeprecatedHandler(RestRequest.Method.GET, "/_xpack/migration/assistance", this,
"[GET _xpack/migration/assistance] is deprecated. " +
"Use [GET _xpack/migration/deprecations] instead.", deprecationLogger);
controller.registerAsDeprecatedHandler(RestRequest.Method.GET, "/_xpack/migration/assistance/{index}", this,
"[GET _xpack/migration/assistance/{index}] is deprecated. " +
"Use [GET _xpack/migration/deprecations?index={index}] instead.", deprecationLogger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public void testGenericTest() throws Exception {

}


private ClusterState mockClusterState(IndexMetaData... indices) {
MetaData.Builder metaDataBuilder = MetaData.builder();
for (IndexMetaData indexMetaData : indices) {
Expand Down