Skip to content

Commit f5a9f2d

Browse files
committed
If the cluster does not contain any indices then index templates do not survive cluster restart, closes elastic#617.
1 parent a0a714e commit f5a9f2d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ public LocalGatewayStartedShards currentStartedShards() {
152152
listener.onSuccess();
153153
return;
154154
}
155-
if (electedState.state().metaData().indices().isEmpty()) {
156-
logger.debug("no indices in metadata");
157-
listener.onSuccess();
158-
return;
159-
}
160155

161156
logger.debug("elected state from [{}]", electedState.node());
162157
final LocalGatewayMetaState state = electedState.state();
@@ -179,6 +174,10 @@ public LocalGatewayStartedShards currentStartedShards() {
179174
}
180175

181176
@Override public void clusterStateProcessed(ClusterState clusterState) {
177+
if (state.metaData().indices().isEmpty()) {
178+
listener.onSuccess();
179+
return;
180+
}
182181
// go over the meta data and create indices, we don't really need to copy over
183182
// the meta data per index, since we create the index and it will be added automatically
184183
for (final IndexMetaData indexMetaData : state.metaData()) {

modules/elasticsearch/src/main/java/org/elasticsearch/gateway/shared/SharedStorageGateway.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ private void updateClusterStateFromGateway(final MetaData fMetaData, final Gatew
149149
}
150150

151151
@Override public void clusterStateProcessed(ClusterState clusterState) {
152+
if (fMetaData.indices().isEmpty()) {
153+
listener.onSuccess();
154+
return;
155+
}
152156
// go over the meta data and create indices, we don't really need to copy over
153157
// the meta data per index, since we create the index and it will be added automatically
154158
for (final IndexMetaData indexMetaData : fMetaData) {

0 commit comments

Comments
 (0)