Skip to content

Commit

Permalink
Do not open indices with broken index settings
Browse files Browse the repository at this point in the history
- remove the leniency on opening indices with unrecognized settings and
instead such an index will be closed
with the unrecognized settings archived
- do not open any index with archived settings
- users can remove archived settings via the wildcard archived
- return illegal_argument_exception 400 status code when trying
to open an index with broken/archived settings

Relates to elastic#26995

Closes elastic#26998
  • Loading branch information
mayya-sharipova committed Mar 16, 2018
1 parent eca5483 commit 08daa7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.elasticsearch.action.admin.indices.create;

import com.carrotsearch.hppc.cursors.ObjectCursor;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.UnavailableShardsException;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
Expand Down Expand Up @@ -394,7 +393,8 @@ public Settings onNodeStopped(String nodeName) throws Exception {
final Exception e =
expectThrows(IllegalArgumentException.class, () -> client().admin().indices().prepareOpen("test").get());
assertThat(e, hasToString(containsString("Failed to verify index " + metaData.getIndex())));
assertThat(e, hasToString(containsString("unknown setting [index.foo]")));
assertNotNull(e.getCause());
assertThat(e.getCause().getMessage(), hasToString(containsString("unknown setting [index.foo]")));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ public void testDoNotOpenIndexWithUnknownOrAchivedSettings() throws Exception {
// try to open it with the archived setting - fail again with IndexOpenException
Exception ex = expectThrows(IllegalArgumentException.class, () -> client().admin().indices().prepareOpen("test").get());
assertThat(ex.getMessage(), startsWith("Failed to open index! Failed to verify index " + metaData.getIndex()));
assertThat(ex.getMessage(), containsString("unknown setting [archived.index.unknown.setting]"));
assertNotNull(ex.getCause());
assertEquals(IllegalArgumentException.class, ex.getCause().getClass());
assertThat(ex.getCause().getMessage(), startsWith("unknown setting [archived.index.unknown.setting]"));

// delete archived settings and try to open index again - this time successful
client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().putNull("archived.*")).get();
Expand Down Expand Up @@ -481,7 +483,8 @@ public void testRecoverMissingAnalyzer() throws Exception {
// try to open it with the broken setting - fail again!
Exception ex = expectThrows(IllegalArgumentException.class, () -> client().admin().indices().prepareOpen("test").get());
assertThat(ex.getMessage(), startsWith("Failed to open index! Failed to verify index " + metaData.getIndex()));
assertThat(ex.getMessage(), containsString("analyzer [test] not found for field [field1]"));
assertNotNull(ex.getCause());
assertThat(ex.getCause().getMessage(), containsString("analyzer [test] not found for field [field1]"));
}

public void testArchiveBrokenClusterSettings() throws Exception {
Expand Down

0 comments on commit 08daa7c

Please sign in to comment.