Skip to content

Commit

Permalink
fix(discovery): do not fail startup if plugin ping fails (#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Oct 10, 2023
1 parent e9ddcaf commit 026f0e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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

0 comments on commit 026f0e8

Please sign in to comment.