Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(discovery): do not fail startup if plugin ping fails #1700

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/main/java/io/cryostat/discovery/DiscoveryStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,25 @@ public void stop() {
}
}

private CompletableFuture<?> pingPrune() {
List<CompletableFuture<Boolean>> futures =
private CompletableFuture<Void> pingPrune() {
List<CompletableFuture<Void>> futures =
dao.getAll().stream()
.map(
plugin -> {
UUID key = plugin.getId();
URI uri = plugin.getCallback();
return ping(HttpMethod.POST, uri)
.whenComplete(
.<Void>handle(
(v, t) -> {
if (t != null || !Boolean.TRUE.equals(v)) {
if (t != null) {
logger.warn(
ExceptionUtils
.getStackTrace(t));
}
removePlugin(key, uri);
}
return null;
});
})
.toList();
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/io/cryostat/discovery/DiscoveryStorageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ void removesPluginsIfCallbackRejected() throws Exception {

@Test
void removesPluginsIfCallbackFails() throws Exception {
Mockito.when(deployer.deploy(Mockito.any(), Mockito.anyBoolean()))
.thenReturn(Future.succeededFuture());
EnvironmentNode realm =
new EnvironmentNode("realm", BaseNodeType.REALM, Map.of(), Set.of());
PluginInfo plugin =
Expand Down
Loading