Upgrade API: upgrade assistance shouldn't throw 404 on an empty cluster (elastic/x-pack-elasticsearch#1997)
When a user asks for upgrade information for all indices and there are no indices in the cluster, upgrade assistance should just return an empty response indicating that no indices require upgrade or reindexing. This commit also reverts the temporary fix in WatchBackwardsCompatibilityIT tests that was added as a workaround for this issue. Original commit: elastic/x-pack-elasticsearch@2ea9707867
This commit is contained in:
parent
dd11fc3d0a
commit
4de6d9ebe5
|
@ -124,7 +124,7 @@ public class IndexUpgradeInfoAction extends Action<IndexUpgradeInfoAction.Reques
|
|||
public static class Request extends MasterNodeReadRequest<Request> implements IndicesRequest.Replaceable {
|
||||
|
||||
private String[] indices = null;
|
||||
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, true);
|
||||
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true);
|
||||
|
||||
// for serialization
|
||||
public Request() {
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.elasticsearch.action.support.PlainActionFuture;
|
|||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.index.reindex.BulkByScrollResponse;
|
||||
import org.elasticsearch.tasks.TaskId;
|
||||
import org.elasticsearch.transport.TransportResponse;
|
||||
|
@ -23,6 +24,7 @@ import java.util.Collections;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
|
||||
|
@ -122,4 +124,12 @@ public class IndexUpgradeIT extends IndexUpgradeIntegTestCase {
|
|||
assertTrue(postUpgradeIsCalled.get());
|
||||
}
|
||||
|
||||
public void testIndexUpgradeInfoOnEmptyCluster() {
|
||||
// On empty cluster asking for all indices shouldn't fail since no indices means nothing needs to be upgraded
|
||||
Response response = client().prepareExecute(IndexUpgradeInfoAction.INSTANCE).setIndices("_all").get();
|
||||
assertThat(response.getActions().entrySet(), empty());
|
||||
|
||||
// but calling on a particular index should fail
|
||||
assertThrows(client().prepareExecute(IndexUpgradeInfoAction.INSTANCE).setIndices("test"), IndexNotFoundException.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,9 +163,7 @@ public class WatchBackwardsCompatibilityIT extends ESRestTestCase {
|
|||
try (RestClient client = buildClient(restClientSettings(), newHosts)) {
|
||||
logger.info("checking that upgrade procedure on the new cluster is required, hosts [{}]", Arrays.asList(newHosts));
|
||||
Map<String, String> params = Collections.singletonMap("error_trace", "true");
|
||||
Map<String, String> assistanceParams = new HashMap<>(params);
|
||||
assistanceParams.put("ignore", "404");
|
||||
Map<String, Object> response = toMap(client().performRequest("GET", "_xpack/migration/assistance", assistanceParams));
|
||||
Map<String, Object> response = toMap(client().performRequest("GET", "_xpack/migration/assistance", params));
|
||||
String action = ObjectPath.evaluate(response, "indices.\\.watches.action_required");
|
||||
logger.info("migration assistance response [{}]", action);
|
||||
if ("upgrade".equals(action)) {
|
||||
|
|
Loading…
Reference in New Issue