Skip to content

Commit b96ea85

Browse files
committed
refactor: move jvm config to controller/build and remove filename constants
1 parent 420f917 commit b96ea85

7 files changed

Lines changed: 26 additions & 25 deletions

File tree

rust/operator-binary/src/config/mod.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

rust/operator-binary/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use crate::{
4040
};
4141

4242
mod command;
43-
mod config;
4443
pub mod crd;
4544
mod framework;
4645
mod listener;

rust/operator-binary/src/zk_controller.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ use strum::{EnumDiscriminants, IntoStaticStr};
6565
use crate::{
6666
APP_NAME, OPERATOR_NAME, ObjectRef,
6767
command::create_init_container_command_args,
68-
config::jvm::{construct_non_heap_jvm_args, construct_zk_server_heap_env},
6968
crd::{
7069
JMX_METRICS_PORT_NAME, METRICS_PROVIDER_HTTP_PORT_NAME, STACKABLE_CONFIG_DIR,
7170
STACKABLE_DATA_DIR, STACKABLE_LOG_CONFIG_DIR, STACKABLE_LOG_DIR, STACKABLE_RW_CONFIG_DIR,
@@ -80,6 +79,10 @@ use crate::{
8079
self, build_server_rolegroup_headless_service, build_server_rolegroup_metrics_service,
8180
},
8281
utils::build_recommended_labels,
82+
zk_controller::build::{
83+
jvm::{construct_non_heap_jvm_args, construct_zk_server_heap_env},
84+
properties::ConfigFileName,
85+
},
8386
};
8487

8588
pub(crate) mod build;
@@ -231,7 +234,7 @@ pub enum Error {
231234
},
232235

233236
#[snafu(display("failed to construct JVM arguments"))]
234-
ConstructJvmArguments { source: crate::config::jvm::Error },
237+
ConstructJvmArguments { source: build::jvm::Error },
235238

236239
#[snafu(display("failed to apply group listener"))]
237240
ApplyGroupListener {
@@ -656,10 +659,11 @@ fn build_server_rolegroup_statefulset(
656659
{remove_vector_shutdown_file_command}
657660
prepare_signal_handlers
658661
containerdebug --output={STACKABLE_LOG_DIR}/containerdebug-state.json --loop &
659-
bin/zkServer.sh start-foreground {STACKABLE_RW_CONFIG_DIR}/zoo.cfg &
662+
bin/zkServer.sh start-foreground {STACKABLE_RW_CONFIG_DIR}/{zoo_cfg} &
660663
wait_for_termination $!
661664
{create_vector_shutdown_file_command}
662665
",
666+
zoo_cfg = ConfigFileName::ZooCfg,
663667
remove_vector_shutdown_file_command =
664668
remove_vector_shutdown_file_command(STACKABLE_LOG_DIR),
665669
create_vector_shutdown_file_command =

rust/operator-binary/src/zk_controller/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
88
pub mod config_map;
99
pub mod discovery;
10+
pub mod jvm;
1011
pub mod properties;

rust/operator-binary/src/config/jvm.rs renamed to rust/operator-binary/src/zk_controller/build/jvm.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,14 @@ use stackable_operator::{
44
role_utils::{self, JvmArgumentOverrides},
55
};
66

7+
use super::properties::ConfigFileName;
78
use crate::crd::{
89
JMX_METRICS_PORT, LoggingFramework, STACKABLE_CONFIG_DIR, STACKABLE_LOG_CONFIG_DIR,
910
ZookeeperServerRoleType, logging_framework, v1alpha1::ZookeeperConfig,
1011
};
1112

1213
const JAVA_HEAP_FACTOR: f32 = 0.8;
1314

14-
/// The JVM security properties file the operator writes into the rolegroup
15-
/// ConfigMap (see `zk_controller::build::properties::ConfigFileName`).
16-
const JVM_SECURITY_PROPERTIES_FILE: &str = "security.properties";
17-
18-
/// The log config files the JVM is pointed at via system properties. These are
19-
/// written by `zk_controller::build::properties::logging`.
20-
const LOG4J_CONFIG_FILE: &str = "log4j.properties";
21-
const LOGBACK_CONFIG_FILE: &str = "logback.xml";
22-
2315
#[derive(Snafu, Debug)]
2416
pub enum Error {
2517
#[snafu(display("invalid memory resource configuration - missing default or value in crd?"))]
@@ -43,16 +35,21 @@ fn construct_jvm_args(
4335
let logging_framework = logging_framework(product_version);
4436

4537
let jvm_args = vec![
46-
format!("-Djava.security.properties={STACKABLE_CONFIG_DIR}/{JVM_SECURITY_PROPERTIES_FILE}"),
38+
format!(
39+
"-Djava.security.properties={STACKABLE_CONFIG_DIR}/{}",
40+
ConfigFileName::SecurityProperties
41+
),
4742
format!(
4843
"-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar={JMX_METRICS_PORT}:/stackable/jmx/server.yaml"
4944
),
5045
match logging_framework {
51-
LoggingFramework::LOG4J => {
52-
format!("-Dlog4j.configuration=file:{STACKABLE_LOG_CONFIG_DIR}/{LOG4J_CONFIG_FILE}")
53-
}
46+
LoggingFramework::LOG4J => format!(
47+
"-Dlog4j.configuration=file:{STACKABLE_LOG_CONFIG_DIR}/{config_file}",
48+
config_file = ConfigFileName::Log4jProperties
49+
),
5450
LoggingFramework::LOGBACK => format!(
55-
"-Dlogback.configurationFile={STACKABLE_LOG_CONFIG_DIR}/{LOGBACK_CONFIG_FILE}"
51+
"-Dlogback.configurationFile={STACKABLE_LOG_CONFIG_DIR}/{config_file}",
52+
config_file = ConfigFileName::LogbackXml
5653
),
5754
},
5855
];

rust/operator-binary/src/zk_controller/build/properties/logging.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ use stackable_operator::{
1313
role_utils::RoleGroupRef,
1414
};
1515

16+
use super::ConfigFileName;
1617
use crate::crd::{LoggingFramework, STACKABLE_LOG_DIR, v1alpha1};
1718

18-
/// The logback config file name (when the product uses the LOGBACK framework).
19-
pub const LOGBACK_CONFIG_FILE: &str = "logback.xml";
20-
/// The log4j config file name (when the product uses the LOG4J framework).
21-
pub const LOG4J_CONFIG_FILE: &str = "log4j.properties";
2219
/// The file the ZooKeeper server logs are written to.
2320
pub const ZOOKEEPER_LOG_FILE: &str = "zookeeper.log4j.xml";
2421

@@ -57,7 +54,7 @@ pub fn build(
5754
match framework {
5855
LoggingFramework::LOG4J => {
5956
data.insert(
60-
LOG4J_CONFIG_FILE.to_string(),
57+
ConfigFileName::Log4jProperties.to_string(),
6158
product_logging::framework::create_log4j_config(
6259
&log_dir,
6360
ZOOKEEPER_LOG_FILE,
@@ -69,7 +66,7 @@ pub fn build(
6966
}
7067
LoggingFramework::LOGBACK => {
7168
data.insert(
72-
LOGBACK_CONFIG_FILE.to_string(),
69+
ConfigFileName::LogbackXml.to_string(),
7370
product_logging::framework::create_logback_config(
7471
&log_dir,
7572
ZOOKEEPER_LOG_FILE,

rust/operator-binary/src/zk_controller/build/properties/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ pub enum ConfigFileName {
1414
ZooCfg,
1515
#[strum(serialize = "security.properties")]
1616
SecurityProperties,
17+
#[strum(serialize = "log4j.properties")]
18+
Log4jProperties,
19+
#[strum(serialize = "logback.xml")]
20+
LogbackXml,
1721
}

0 commit comments

Comments
 (0)