Skip to content

Commit

Permalink
fix(discovery): check container discovery domain socket readability b…
Browse files Browse the repository at this point in the history
…efore start
  • Loading branch information
andrewazores committed Jan 22, 2024
1 parent 1897edb commit 3d5015d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/io/cryostat/discovery/ContainerDiscovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand All @@ -36,6 +37,7 @@

import io.cryostat.URIUtil;
import io.cryostat.core.net.JFRConnectionToolkit;
import io.cryostat.core.sys.FileSystem;
import io.cryostat.targets.Target;
import io.cryostat.targets.Target.Annotations;
import io.cryostat.targets.Target.EventKind;
Expand Down Expand Up @@ -131,6 +133,7 @@ public abstract class ContainerDiscovery {
public static final String JMX_PORT_LABEL = "io.cryostat.jmxPort";

@Inject Logger logger;
@Inject FileSystem fs;
@Inject Vertx vertx;
@Inject WebClient webClient;
@Inject JFRConnectionToolkit connectionToolkit;
Expand All @@ -146,6 +149,15 @@ void onStart(@Observes StartupEvent evt) {
return;
}

Path socketPath = Path.of(getSocket().path());
if (!(fs.isRegularFile(socketPath) && fs.isReadable(socketPath))) {
logger.errorv(
"{0} enabled but socket {1} is not accessible!",
getClass().getName(), socketPath);
return;
}
logger.infov("{0} started", getClass().getName());

DiscoveryNode universe = DiscoveryNode.getUniverse();
if (DiscoveryNode.getRealm(getRealm()).isEmpty()) {
DiscoveryPlugin plugin = new DiscoveryPlugin();
Expand Down

0 comments on commit 3d5015d

Please sign in to comment.