Skip to content

Commit

Permalink
Add more trace logging when installing monitor watches and
Browse files Browse the repository at this point in the history
unmute TransportMonitoringMigrateAlertsActionTests#testLocalAlertsRemoval and
TransportMonitoringMigrateAlertsActionTests#testRepeatedLocalAlertsRemoval tests

Somehow during these tests the monitor watches are not installed. Both
tests use the local exporter and this exporter only installs the watches
under specific conditions via the elected master node. I suspect the
conditions are never met. The http exporter is more relaxed when attempting
to install monitor watches and the tests using the http exporter seem
not to be prone by the fact that tests fail because monitor watches have
not been installed.

Relates to elastic#66586
  • Loading branch information
martijnvg committed Feb 9, 2021
1 parent 4660fae commit 5d4a771
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,20 @@ private void setupClusterAlertsTasks(ClusterState clusterState, boolean clusterS
if (watches != null && watches.allPrimaryShardsActive() == false) {
logger.trace("cannot manage cluster alerts because [.watches] index is not allocated");
} else if ((watches == null || indexExists) && watcherSetup.compareAndSet(false, true)) {
logger.trace("installing monitoring watches");
getClusterAlertsInstallationAsyncActions(indexExists, asyncActions, pendingResponses);
} else {
logger.trace("skipping installing monitoring watches, watches=[{}], indexExists=[{}], watcherSetup=[{}]",
watches, indexExists, watcherSetup.get());
}
} else {
logger.trace("watches shouldn't be setup, because state=[{}] and clusterStateChange=[{}]", state.get(), clusterStateChange);
}
} else {
logger.trace("watches can't be used, because xpack.watcher.enabled=[{}] and " +
"xpack.monitoring.exporters._local.cluster_alerts.management.enabled=[{}]",
XPackSettings.WATCHER_ENABLED.get(config.settings()),
CLUSTER_ALERTS_MANAGEMENT_SETTING.getConcreteSettingForNamespace(config.name()).get(config.settings()));
}
}

Expand Down Expand Up @@ -577,6 +588,7 @@ private void getClusterAlertsInstallationAsyncActions(final boolean indexExists,
new ResponseActionListener<>("watch", uniqueWatchId, pendingResponses)));
}
} else if (addWatch) {
logger.trace("adding monitoring watch [{}]", uniqueWatchId);
asyncActions.add(() -> putWatch(client, watchId, uniqueWatchId, pendingResponses));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ private void stopMonitoring() {
));
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/66586")
@TestLogging(
value = "org.elasticsearch.xpack.monitoring.exporter.local:trace",
reason = "to ensure we log local exporter on trace level")
Expand Down Expand Up @@ -147,7 +146,6 @@ public void testLocalAlertsRemoval() throws Exception {
}
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/66586")
@TestLogging(
value = "org.elasticsearch.xpack.monitoring.exporter.local:trace",
reason = "to ensure we log local exporter on trace level")
Expand Down

0 comments on commit 5d4a771

Please sign in to comment.