Skip to content

Commit a810031

Browse files
committed
implement jvm overrides for the connect server
1 parent 62f33c6 commit a810031

File tree

7 files changed

+49
-25
lines changed

7 files changed

+49
-25
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ indoc = "2"
3535

3636
# TODO: revert before merging
3737
[patch."https://github.com/stackabletech/operator-rs.git"]
38-
stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "feat/support-deployment" }
38+
stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
3939
# stackable-operator = { path = "../operator-rs/crates/stackable-operator" }

crate-hashes.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/operator-binary/src/connect/controller.rs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use stackable_operator::{
4242
CustomContainerLogConfig,
4343
},
4444
},
45+
role_utils::{JavaCommonConfig, JvmArgumentOverrides},
4546
time::Duration,
4647
};
4748
use strum::{Display, EnumDiscriminants, IntoStaticStr};
@@ -67,6 +68,11 @@ const DUMMY_SPARK_CONNECT_GROUP_NAME: &str = "default";
6768
#[strum_discriminants(derive(IntoStaticStr))]
6869
#[allow(clippy::enum_variant_names)]
6970
pub enum Error {
71+
#[snafu(display("failed to merge jvm argument overrides"))]
72+
MergeJvmArgumentOverrides {
73+
source: stackable_operator::role_utils::Error,
74+
},
75+
7076
#[snafu(display("fragment validation failure"))]
7177
FragmentValidationFailure { source: ValidationError },
7278

@@ -296,7 +302,7 @@ pub async fn reconcile(
296302
.context(ApplyConfigMapSnafu)?;
297303

298304
let args = command_args(&resolved_product_image.product_version);
299-
let sts = build_deployment(
305+
let deployment = build_deployment(
300306
scs,
301307
&connect_config,
302308
&resolved_product_image,
@@ -305,7 +311,7 @@ pub async fn reconcile(
305311
args,
306312
)?;
307313
cluster_resources
308-
.add(client, sts)
314+
.add(client, deployment)
309315
.await
310316
.context(ApplyDeploymentSnafu)?;
311317

@@ -456,7 +462,12 @@ fn build_deployment(
456462
});
457463

458464
let container_env = env(
459-
&jvm_args()?,
465+
&jvm_args(
466+
scs.spec
467+
.server
468+
.as_ref()
469+
.map(|s| &s.product_specific_common_config),
470+
)?,
460471
scs.spec
461472
.server
462473
.as_ref()
@@ -662,17 +673,31 @@ fn object_name(stacklet_name: &str, role: SparkConnectRole) -> String {
662673
}
663674
}
664675

676+
// Returns the jvm arguments a user has provided merged with the operator props.
677+
// The JVM args are passed to spark-connect as SPARK_DAEMON_JAVA_OPTS env var
665678
#[allow(clippy::result_large_err)]
666-
fn jvm_args() -> Result<String, Error> {
667-
let jvm_args = [
679+
fn jvm_args(user_java_config: Option<&JavaCommonConfig>) -> Result<String, Error> {
680+
let jvm_args = vec![
668681
// TODO: fix this when the logging container is fixed
669682
// format!("-Dlog4j.configurationFile={VOLUME_MOUNT_PATH_LOG_CONFIG}/{LOG4J2_CONFIG_FILE}"),
670683
format!(
671684
"-Djava.security.properties={VOLUME_MOUNT_PATH_CONFIG}/{JVM_SECURITY_PROPERTIES_FILE}"
672685
),
673686
format!("-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar={METRICS_PORT}:/stackable/jmx/config.yaml")
674687
];
675-
Ok(jvm_args.join(" "))
688+
689+
if let Some(user_jvm_props) = user_java_config {
690+
let operator_generated = JvmArgumentOverrides::new_with_only_additions(jvm_args.clone());
691+
let mut user_jvm_props_copy = user_jvm_props.jvm_argument_overrides.clone();
692+
user_jvm_props_copy
693+
.try_merge(&operator_generated)
694+
.context(MergeJvmArgumentOverridesSnafu)?;
695+
Ok(user_jvm_props_copy
696+
.effective_jvm_config_after_merging()
697+
.join(" "))
698+
} else {
699+
Ok(jvm_args.join(" "))
700+
}
676701
}
677702

678703
#[allow(clippy::result_large_err)]

tests/templates/kuttl/spark-connect/10-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ kind: TestAssert
44
timeout: 900
55
---
66
apiVersion: apps/v1
7-
kind: StatefulSet
7+
kind: Deployment
88
metadata:
99
name: spark-connect-server
1010
status:

tests/templates/kuttl/spark-connect/10-deploy-spark-connect.yaml.j2

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ spec:
3535
{% if lookup('env', 'VECTOR_AGGREGATOR') %}
3636
vectorAggregatorConfigMapName: vector-aggregator-discovery
3737
{% endif %}
38-
#sparkConf:
39-
nodes:
38+
server:
39+
jvmArgumentOverrides:
40+
add:
41+
- -Xmx800m
4042
config:
4143
logging:
4244
enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }}
4345
containers:
4446
spark-connect:
4547
custom:
4648
configMap: spark-connect-log-config
47-
roleGroups:
48-
default:
49-
replicas: 1

0 commit comments

Comments
 (0)