Skip to content

Commit 5ecba5b

Browse files
authored
Preventing watcher from starting up if its templates are missing (#82395) (#82573)
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 #69328 #82109
1 parent f60e517 commit 5ecba5b

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
@@ -135,13 +135,6 @@ public class WatcherService {
135135
* @return true if everything is good to go, so that the service can be started
136136
*/
137137
public boolean validate(ClusterState state) {
138-
// template check makes only sense for non existing indices, we could refine this
139-
boolean hasValidWatcherTemplates = WatcherIndexTemplateRegistry.validate(state);
140-
if (hasValidWatcherTemplates == false) {
141-
logger.debug("missing watcher index templates, not starting watcher service");
142-
return false;
143-
}
144-
145138
IndexMetadata watcherIndexMetadata = WatchStoreUtils.getConcreteIndex(Watch.INDEX, state.metadata());
146139
IndexMetadata triggeredWatchesIndexMetadata = WatchStoreUtils.getConcreteIndex(
147140
TriggeredWatchStoreField.INDEX_NAME,
@@ -210,6 +203,10 @@ void stopExecutor() {
210203
* @param state cluster state, which is needed to find out about local shards
211204
*/
212205
void reload(ClusterState state, String reason) {
206+
boolean hasValidWatcherTemplates = WatcherIndexTemplateRegistry.validate(state);
207+
if (hasValidWatcherTemplates == false) {
208+
logger.warn("missing watcher index templates");
209+
}
213210
// this method contains the only async code block, being called by the cluster state listener
214211
// 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
215212
// thread

0 commit comments

Comments
 (0)