Watcher: Ignore if template is missing when upgrade is running (elastic/x-pack-elasticsearch#2199)
If one of the old watcher templates does not exist when we try to delete it, the upgrade should just continue. Original commit: elastic/x-pack-elasticsearch@6a52bad329
This commit is contained in:
parent
1d6f82dbe3
commit
55e88d6857
|
@ -29,6 +29,7 @@ import org.elasticsearch.common.settings.SettingsFilter;
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.index.IndexNotFoundException;
|
import org.elasticsearch.index.IndexNotFoundException;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
|
import org.elasticsearch.indices.IndexTemplateMissingException;
|
||||||
import org.elasticsearch.plugins.ActionPlugin;
|
import org.elasticsearch.plugins.ActionPlugin;
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
import org.elasticsearch.rest.RestHandler;
|
import org.elasticsearch.rest.RestHandler;
|
||||||
|
@ -290,13 +291,22 @@ public class Upgrade implements ActionPlugin {
|
||||||
|
|
||||||
private static ActionListener<DeleteIndexTemplateResponse> deleteIndexTemplateListener(String name, ActionListener<Boolean> listener,
|
private static ActionListener<DeleteIndexTemplateResponse> deleteIndexTemplateListener(String name, ActionListener<Boolean> listener,
|
||||||
Runnable runnable) {
|
Runnable runnable) {
|
||||||
return ActionListener.wrap(r -> {
|
return ActionListener.wrap(
|
||||||
if (r.isAcknowledged()) {
|
r -> {
|
||||||
runnable.run();
|
if (r.isAcknowledged()) {
|
||||||
} else {
|
runnable.run();
|
||||||
listener.onFailure(new ElasticsearchException("Deleting [{}] template was not acknowledged", name));
|
} else {
|
||||||
}
|
listener.onFailure(new ElasticsearchException("Deleting [{}] template was not acknowledged", name));
|
||||||
}, listener::onFailure);
|
}
|
||||||
|
},
|
||||||
|
// if the index template we tried to delete is gone already, no need to worry
|
||||||
|
e -> {
|
||||||
|
if (e instanceof IndexTemplateMissingException) {
|
||||||
|
runnable.run();
|
||||||
|
} else {
|
||||||
|
listener.onFailure(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void startWatcherIfNeeded(Boolean shouldStartWatcher, Client client, ActionListener<TransportResponse.Empty> listener) {
|
private static void startWatcherIfNeeded(Boolean shouldStartWatcher, Client client, ActionListener<TransportResponse.Empty> listener) {
|
||||||
|
|
Loading…
Reference in New Issue