Skip to content

Commit

Permalink
feat(plugin): send additional platform env extras to plugins on regis…
Browse files Browse the repository at this point in the history
…tration
  • Loading branch information
andrewazores committed Jun 6, 2023
1 parent 3a298af commit 3ff806c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
6 changes: 3 additions & 3 deletions smoketest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ runDemoApps() {
--label io.cryostat.discovery="true" \
--label io.cryostat.jmxHost="localhost" \
--label io.cryostat.jmxPort="9093" \
--rm -d quay.io/andrewazores/vertx-fib-demo:0.12.2
--rm -d quay.io/andrewazores/vertx-fib-demo:0.12.4

podman run \
--name vertx-fib-demo-2 \
Expand All @@ -146,7 +146,7 @@ runDemoApps() {
--label io.cryostat.jmxHost="localhost" \
--label io.cryostat.jmxPort="9094" \
--label io.cryostat.jmxUrl="service:jmx:rmi:///jndi/rmi://localhost:9094/jmxrmi" \
--rm -d quay.io/andrewazores/vertx-fib-demo:0.12.2
--rm -d quay.io/andrewazores/vertx-fib-demo:0.12.4

podman run \
--name vertx-fib-demo-3 \
Expand All @@ -166,7 +166,7 @@ runDemoApps() {
--pod cryostat-pod \
--label io.cryostat.discovery="true" \
--label io.cryostat.jmxUrl="service:jmx:rmi:///jndi/rmi://localhost:9095/jmxrmi" \
--rm -d quay.io/andrewazores/vertx-fib-demo:0.12.2
--rm -d quay.io/andrewazores/vertx-fib-demo:0.12.4

# this config is broken on purpose (missing required env vars) to test the agent's behaviour
# when not properly set up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class DiscoveryRegistrationHandler extends AbstractV2RequestHandler<Map<String,
DiscoveryStorage storage,
Lazy<WebServer> webServer,
@Named(PlatformModule.SELECTED_PLATFORMS)
Set<PlatformDetectionStrategy<?>> selectedStrategies,
Set<PlatformDetectionStrategy<?>> selectedStrategies,
DiscoveryJwtHelper jwt,
@Named(MainModule.UUID_FROM_STRING) Function<String, UUID> uuidFromString,
Gson gson,
Expand Down Expand Up @@ -205,6 +205,10 @@ public IntermediateResponse<Map<String, Object>> handle(RequestParameters params
address,
AbstractDiscoveryJwtConsumingHandler.getResourceUri(hostUrl, pluginId));
Map<String, String> mergedEnv = new HashMap<>();
// FIXME currently only the OpenShiftPlatformStrategy provides any entries for the env map,
// but in the future if any more strategies also provide entries then the order here may be
// undefined and the map entries may collide and be overwritten. There should be some
// prefixing scheme to prevent collisions.
selectedStrategies.forEach(s -> mergedEnv.putAll(s.environment()));
return new IntermediateResponse<Map<String, Object>>()
.statusCode(201)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
*/
package io.cryostat.platform.internal;

import java.io.IOException;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

import io.cryostat.core.log.Logger;
import io.cryostat.core.net.JFRConnectionToolkit;
import io.cryostat.core.sys.Environment;
import io.cryostat.core.sys.FileSystem;
import io.cryostat.net.AuthManager;

import java.io.IOException;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

import dagger.Lazy;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.openshift.client.OpenShiftClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
package io.cryostat.platform.internal;

import java.net.URI;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -161,6 +163,12 @@ public AuthManager getAuthManager() {
return authMgr.get();
}

// FIXME remove this, just for testing purposes
@Override
public Map<String, String> environment() {
return Map.of("TEST", UUID.randomUUID().toString());
}

private static String getSocketPath() {
long uid = new UnixSystem().getUid();
String socketPath = String.format("/run/user/%d/podman/podman.sock", uid);
Expand Down

0 comments on commit 3ff806c

Please sign in to comment.