Skip to content

Commit 7a4586f

Browse files
committed
Preventing watcher from starting up if its templates are missing (elastic#82395)
This commit prevents watcher from failing to start if its templates are unavailable. Previously the watcher service would fail to start if (for example) the .watch-history-14 template did not exist. This could happen during a rolling upgrade. In that case, the watcher service would fail to start even though it could reasonably keep writing without its templates. Relates elastic#69328 elastic#82109
1 parent c17aef1 commit 7a4586f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherService.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ public class WatcherService {
136136
* @return true if everything is good to go, so that the service can be started
137137
*/
138138
public boolean validate(ClusterState state) {
139-
// template check makes only sense for non existing indices, we could refine this
140-
boolean hasValidWatcherTemplates = WatcherIndexTemplateRegistry.validate(state);
141-
if (hasValidWatcherTemplates == false) {
142-
logger.debug("missing watcher index templates, not starting watcher service");
143-
return false;
144-
}
145-
146139
IndexMetadata watcherIndexMetadata = WatchStoreUtils.getConcreteIndex(Watch.INDEX, state.metadata());
147140
IndexMetadata triggeredWatchesIndexMetadata = WatchStoreUtils.getConcreteIndex(
148141
TriggeredWatchStoreField.INDEX_NAME,
@@ -211,6 +204,10 @@ void stopExecutor() {
211204
* @param state cluster state, which is needed to find out about local shards
212205
*/
213206
void reload(ClusterState state, String reason) {
207+
boolean hasValidWatcherTemplates = WatcherIndexTemplateRegistry.validate(state);
208+
if (hasValidWatcherTemplates == false) {
209+
logger.warn("missing watcher index templates");
210+
}
214211
// this method contains the only async code block, being called by the cluster state listener
215212
// the reason for this is, that loading he watches is done in a sync manner and thus cannot be done on the cluster state listener
216213
// thread

0 commit comments

Comments
 (0)