Skip to content

Commit 2eb2554

Browse files
committed
Merge branch 'metrics-jdk-options' into 'main'
Prepare for future release of WME by switching Java options env. variable See merge request weblogic-cloud/weblogic-kubernetes-operator!5035
2 parents deec72a + ec97095 commit 2eb2554

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/MonitoringUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ public static boolean verifyMonExpAppAccess(String uri, String searchKey, Boolea
13611361
}
13621362
// access metrics
13631363
final String command = String.format(
1364-
"%s exec -n %s %s -- curl -k %s://%s:%s@%s:%s/%s",
1364+
"%s exec -c weblogic-server -n %s %s -- curl -k %s://%s:%s@%s:%s/%s",
13651365
KUBERNETES_CLI,
13661366
domainNS,
13671367
podName,
@@ -1446,7 +1446,8 @@ public static String replaceValueInFile(String tempFileName, String srcFileName,
14461446
public static boolean verifyMonExpAppAccessSideCar(String searchKey,
14471447
String domainNS, String podName) {
14481448
// access metrics
1449-
final String command = String.format("%s exec -n %s %s -- curl -X GET -u %s:%s http://localhost:8080/metrics",
1449+
final String command = String.format(
1450+
"%s exec -c weblogic-server -n %s %s -- curl -X GET -u %s:%s http://localhost:8080/metrics",
14501451
KUBERNETES_CLI, domainNS, podName, ADMIN_USERNAME_DEFAULT, ADMIN_PASSWORD_DEFAULT);
14511452

14521453
logger.info("accessing managed server exporter via " + command);

operator/src/main/java/oracle/kubernetes/operator/helpers/PodStepContext.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,13 @@ private void restoreMetricsExporterSidecarPortTcpMetrics(V1Pod recipe, V1Pod cur
12701270
.findFirst()).ifPresent(p -> p.setName("tcp-metrics"));
12711271
}
12721272

1273+
private void restoreMetricsExporterSidecarJavaOpts(V1Pod recipe, V1Pod currentPod) {
1274+
V1PodSpec podSpec = recipe.getSpec();
1275+
stream(podSpec.getContainers()).filter(c -> "monitoring-exporter".equals(c.getName()))
1276+
.findFirst().flatMap(c -> stream(c.getEnv()).filter(p -> "JDK_JAVA_OPTIONS".equals(p.getName()))
1277+
.findFirst()).ifPresent(p -> p.setName("JAVA_OPTS"));
1278+
}
1279+
12731280
private void restoreLegacyIstioPortsConfig(V1Pod recipePod, V1Pod currentPod) {
12741281
V1PodSpec recipePodSpec = recipePod.getSpec();
12751282

@@ -1416,6 +1423,7 @@ private boolean canAdjustRecentOperatorMajorVersion3HashToMatch(V1Pod currentPod
14161423
// return true if any adjusted hash matches required hash
14171424
List<Pair<String, BiConsumer<V1Pod, V1Pod>>> adjustments = List.of(
14181425
Pair.of("restoreMetricsExporterSidecarPortTcpMetrics", this::restoreMetricsExporterSidecarPortTcpMetrics),
1426+
Pair.of("restoreMetricsExporterSidecarJavaOpts", this::restoreMetricsExporterSidecarJavaOpts),
14191427
Pair.of("convertAuxImagesInitContainerVolumeAndMounts",
14201428
this::convertAuxImagesInitContainerVolumeAndMounts),
14211429
Pair.of("restoreLegacyIstioPortsConfig", this::restoreLegacyIstioPortsConfig),
@@ -1662,7 +1670,7 @@ private V1Container createMonitoringExporterContainer() {
16621670
.imagePullPolicy(getDomain().getMonitoringExporterImagePullPolicy())
16631671
.resources(getDomain().getMonitoringExporterResources())
16641672
.securityContext(getServerSpec().getContainerSecurityContext())
1665-
.addEnvItem(new V1EnvVar().name("JAVA_OPTS").value(createJavaOptions()))
1673+
.addEnvItem(new V1EnvVar().name("JDK_JAVA_OPTIONS").value(createJavaOptions()))
16661674
.addPortsItem(new V1ContainerPort()
16671675
.name("metrics").protocol("TCP").containerPort(getPort()));
16681676

operator/src/test/java/oracle/kubernetes/operator/helpers/ManagedPodHelperTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ protected boolean matchesSafely(V1Container container, Description mismatchDescr
13911391
if (getJavaOptions(container).contains(expectedOption)) {
13921392
return true;
13931393
} else {
1394-
mismatchDescription.appendText("JAVA_OPTS is ").appendValue(getJavaOptEnv(container));
1394+
mismatchDescription.appendText("JDK_JAVA_OPTIONS is ").appendValue(getJavaOptEnv(container));
13951395
return false;
13961396
}
13971397
}
@@ -1406,7 +1406,7 @@ private List<String> getJavaOptions(V1Container container) {
14061406
@Nonnull
14071407
private String getJavaOptEnv(V1Container container) {
14081408
return getEnvironmentVariables(container).stream()
1409-
.filter(env -> "JAVA_OPTS".equals(env.getName()))
1409+
.filter(env -> "JDK_JAVA_OPTIONS".equals(env.getName()))
14101410
.map(V1EnvVar::getValue)
14111411
.findFirst()
14121412
.orElse("");
@@ -1419,7 +1419,7 @@ private List<V1EnvVar> getEnvironmentVariables(V1Container container) {
14191419

14201420
@Override
14211421
public void describeTo(Description description) {
1422-
description.appendText("JAVA_OPTS containing ").appendValue(expectedOption);
1422+
description.appendText("JDK_JAVA_OPTIONS containing ").appendValue(expectedOption);
14231423
}
14241424
}
14251425

0 commit comments

Comments
 (0)