Skip to content

Commit

Permalink
Merge branch 'main' of github.com:cryostatio/cryostat
Browse files Browse the repository at this point in the history
  • Loading branch information
aali309 committed Feb 15, 2024
2 parents c7c4e2d + 838affd commit 959101c
Show file tree
Hide file tree
Showing 11 changed files with 1,342 additions and 804 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,9 @@ jobs:
restore-keys: |
${{ runner.os }}-build-
${{ runner.os }}-
- name: maven-settings
uses: s4u/maven-settings-action@v2
with:
githubServer: true
- run: git submodule init
- run: git submodule update
- run: mvn -B -U -Dbuild.arch=${{ inputs.build-arch }} clean package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save cryostat image
run: podman save -o cryostat-${{ inputs.build-arch }}.tar --format oci-archive quay.io/cryostat/cryostat
- uses: actions/upload-artifact@v3
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/ci-code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,8 @@ jobs:
with:
java-version: '17'
distribution: 'temurin'
- name: maven-settings
uses: s4u/maven-settings-action@v2
with:
servers: '[{"id": "github", "username": "dummy", "password": "${env.GITHUB_TOKEN}"}]'
githubServer: false
- name: Run spotbugs
run: mvn -B -U -Dheadless=true compile spotbugs:check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

shellcheck:
runs-on: ubuntu-latest
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/integrated-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ jobs:
restore-keys: |
${{ runner.os }}-build-
${{ runner.os }}-
- name: maven-settings
uses: s4u/maven-settings-action@v2
with:
githubServer: true
- name: ghcr login
uses: redhat-actions/podman-login@v1
with:
Expand All @@ -70,8 +66,6 @@ jobs:
run: podman tag ghcr.io/${{ github.repository_owner }}/cryostat:pr-${{ inputs.pr-number }}-${{ inputs.sha-value }}-linux-${{ inputs.build-arch}} quay.io/cryostat/cryostat
- name: Run integration tests
run: POD_NAME=cryostat-itests CONTAINER_NAME=cryostat-itest ITEST_IMG_VERSION=latest bash repeated-integration-tests.bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print itest logs
if: failure()
run: ls -1dt target/cryostat-itest-*.log | head -n1 | xargs cat
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,14 @@ service endpoints and expose all discovered services as potential targets. This
is runtime dynamic, allowing `cryostat` to discover new services which come
online after `cryostat`, or to detect when known services disappear later.
This requires the `cryostat` pod to have authorization to list services
within its own namespace.
within its own namespace. By default this will look for `Endpoints` objects
with ports named `jfr-jmx` or numbered `9091`. This behaviour can be overridden
using the environment variables `CRYOSTAT_DISCOVERY_K8S_PORT_NAMES` and
`CRYOSTAT_DISCOVERY_K8S_PORT_NUMBERS` respectively. Both of these accept
comma-separated lists as values. Any observed `Endpoints` object with a name
in the given list or a number in the given list will be taken as a connectable
target application. To set the names list to the empty list use `-`. To set the
numbers list to the empty list use `0`.

The second discovery mechanism is JDP (Java Discovery Protocol). This relies on
target JVMs being configured with the JVM flags to enable JDP and requires the
Expand Down
9 changes: 1 addition & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
<name>cryostat</name>
<url>http://maven.apache.org</url>

<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/cryostatio/cryostat-core</url>
</repository>
</repositories>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
Expand Down Expand Up @@ -85,7 +78,7 @@
<com.google.dagger.version>2.47</com.google.dagger.version>
<com.google.dagger.compiler.version>${com.google.dagger.version}</com.google.dagger.compiler.version>

<io.cryostat.core.version>2.27.0</io.cryostat.core.version>
<io.cryostat.core.version>2.28.0</io.cryostat.core.version>

<org.openjdk.nashorn.core.version>15.4</org.openjdk.nashorn.core.version>
<org.apache.commons.lang3.version>3.13.0</org.apache.commons.lang3.version>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/cryostat/configuration/Variables.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ private Variables() {}
public static final String DISABLE_BUILTIN_DISCOVERY = "CRYOSTAT_DISABLE_BUILTIN_DISCOVERY";
public static final String DISCOVERY_PING_PERIOD_MS = "CRYOSTAT_DISCOVERY_PING_PERIOD";
public static final String K8S_NAMESPACES = "CRYOSTAT_K8S_NAMESPACES";
public static final String K8S_PORT_NAMES = "CRYOSTAT_DISCOVERY_K8S_PORT_NAMES";
public static final String K8S_PORT_NUMBERS = "CRYOSTAT_DISCOVERY_K8S_PORT_NUMBERS";
public static final String VERTX_POOL_SIZE = "CRYOSTAT_VERTX_POOL_SIZE";

// webserver configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import javax.management.remote.JMXServiceURL;

import io.cryostat.core.log.Logger;
import io.cryostat.core.net.JFRConnectionToolkit;
import io.cryostat.core.net.discovery.JvmDiscoveryClient.EventKind;
import io.cryostat.core.sys.Environment;
import io.cryostat.platform.AbstractPlatformClient;
Expand All @@ -44,7 +43,6 @@
import io.cryostat.platform.discovery.NodeType;
import io.cryostat.platform.discovery.TargetNode;

import dagger.Lazy;
import io.fabric8.kubernetes.api.model.EndpointAddress;
import io.fabric8.kubernetes.api.model.EndpointPort;
import io.fabric8.kubernetes.api.model.EndpointSubset;
Expand All @@ -68,6 +66,8 @@ public class KubeApiPlatformClient extends AbstractPlatformClient {

private final KubernetesClient k8sClient;
private final Set<String> namespaces;
private final Set<String> portNames;
private final Set<Integer> portNumbers;
private final LazyInitializer<HashMap<String, SharedIndexInformer<Endpoints>>> nsInformers =
new LazyInitializer<HashMap<String, SharedIndexInformer<Endpoints>>>() {
@Override
Expand Down Expand Up @@ -98,7 +98,6 @@ protected HashMap<String, SharedIndexInformer<Endpoints>> initialize()
};
private Integer memoHash;
private EnvironmentNode memoTree;
private final Lazy<JFRConnectionToolkit> connectionToolkit;
private final Logger logger;
private final Map<Triple<String, String, String>, Pair<HasMetadata, EnvironmentNode>>
discoveryNodeCache = new ConcurrentHashMap<>();
Expand All @@ -108,13 +107,15 @@ protected HashMap<String, SharedIndexInformer<Endpoints>> initialize()
KubeApiPlatformClient(
Environment environment,
Collection<String> namespaces,
Collection<String> portNames,
Collection<Integer> portNumbers,
KubernetesClient k8sClient,
Lazy<JFRConnectionToolkit> connectionToolkit,
Logger logger) {
super(environment);
this.namespaces = new HashSet<>(namespaces);
this.portNames = new HashSet<>(portNames);
this.portNumbers = new HashSet<>(portNumbers);
this.k8sClient = k8sClient;
this.connectionToolkit = connectionToolkit;
this.logger = logger;
}

Expand Down Expand Up @@ -289,7 +290,7 @@ private Pair<HasMetadata, EnvironmentNode> queryForNode(
}

private boolean isCompatiblePort(EndpointPort port) {
return "jfr-jmx".equals(port.getName()) || 9091 == port.getPort();
return portNames.contains(port.getName()) || portNumbers.contains(port.getPort());
}

private List<ServiceRef> getAllServiceRefs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import io.cryostat.configuration.Variables;
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;
Expand All @@ -39,21 +38,18 @@

class KubeApiPlatformStrategy implements PlatformDetectionStrategy<KubeApiPlatformClient> {

public static final String NO_PORT_NAME = "-";
public static final Integer NO_PORT_NUMBER = 0;

protected final Lazy<? extends AuthManager> authMgr;
protected final Environment env;
protected final FileSystem fs;
protected final Lazy<JFRConnectionToolkit> connectionToolkit;
protected final Logger logger;

KubeApiPlatformStrategy(
Lazy<? extends AuthManager> authMgr,
Lazy<JFRConnectionToolkit> connectionToolkit,
Environment env,
FileSystem fs,
Logger logger) {
Lazy<? extends AuthManager> authMgr, Environment env, FileSystem fs, Logger logger) {
this.logger = logger;
this.authMgr = authMgr;
this.connectionToolkit = connectionToolkit;
this.env = env;
this.fs = fs;
}
Expand All @@ -72,8 +68,19 @@ public boolean isAvailable() {
@Override
public KubeApiPlatformClient getPlatformClient() {
logger.info("Selected {} Strategy", getClass().getSimpleName());
List<String> portNames =
Arrays.asList(env.getEnv(Variables.K8S_PORT_NAMES, "jfr-jmx").split(",")).stream()
.map(String::strip)
.filter(n -> !NO_PORT_NAME.equals(n))
.toList();
List<Integer> portNumbers =
Arrays.asList(env.getEnv(Variables.K8S_PORT_NUMBERS, "9091").split(",")).stream()
.map(String::strip)
.map(Integer::parseInt)
.filter(n -> !NO_PORT_NUMBER.equals(n))
.toList();
return new KubeApiPlatformClient(
env, getNamespaces(), createClient(), connectionToolkit, logger);
env, getNamespaces(), portNames, portNumbers, createClient(), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package io.cryostat.platform.internal;

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;
Expand All @@ -28,12 +27,8 @@
class OpenShiftPlatformStrategy extends KubeApiPlatformStrategy {

OpenShiftPlatformStrategy(
Lazy<? extends AuthManager> authMgr,
Lazy<JFRConnectionToolkit> connectionToolkit,
Environment env,
FileSystem fs,
Logger logger) {
super(authMgr, connectionToolkit, env, fs, logger);
Lazy<? extends AuthManager> authMgr, Environment env, FileSystem fs, Logger logger) {
super(authMgr, env, fs, logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,15 @@ static CustomTargetPlatformStrategy provideCustomTargetPlatformStrategy(
@Provides
@Singleton
static OpenShiftPlatformStrategy provideOpenShiftPlatformStrategy(
Logger logger,
Lazy<OpenShiftAuthManager> authManager,
Lazy<JFRConnectionToolkit> connectionToolkit,
Environment env,
FileSystem fs) {
return new OpenShiftPlatformStrategy(authManager, connectionToolkit, env, fs, logger);
Lazy<OpenShiftAuthManager> authManager, Environment env, FileSystem fs, Logger logger) {
return new OpenShiftPlatformStrategy(authManager, env, fs, logger);
}

@Provides
@Singleton
static KubeApiPlatformStrategy provideKubeApiPlatformStrategy(
Lazy<NoopAuthManager> noopAuthManager,
Lazy<JFRConnectionToolkit> connectionToolkit,
Environment env,
FileSystem fs,
Logger logger) {
return new KubeApiPlatformStrategy(noopAuthManager, connectionToolkit, env, fs, logger);
Lazy<NoopAuthManager> noopAuthManager, Environment env, FileSystem fs, Logger logger) {
return new KubeApiPlatformStrategy(noopAuthManager, env, fs, logger);
}

@Provides
Expand Down
Loading

0 comments on commit 959101c

Please sign in to comment.