Skip to content

Commit bbaee25

Browse files
committed
refactor: cleanup security properties
1 parent f14e138 commit bbaee25

4 files changed

Lines changed: 118 additions & 212 deletions

File tree

rust/operator-binary/src/controller/build/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::crd::{
1515
/// The JVM options selecting the Kafka log4j/log4j2 config file. Kafka 3.x uses log4j,
1616
/// Kafka 4.0 and higher use log4j2.
1717
pub fn kafka_log_opts(product_version: &str) -> String {
18-
if product_version.starts_with("3.") {
18+
if super::properties::uses_legacy_log4j(product_version) {
1919
format!(
2020
"-Dlog4j.configuration=file:{STACKABLE_LOG_CONFIG_DIR}/{log4j}",
2121
log4j = ConfigFileName::Log4j

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn role_group_config_map_data(
4747
let mut configs: BTreeMap<String, Option<String>> = BTreeMap::new();
4848

4949
// Starting with Kafka 4.0, log4j2 is used instead of log4j.
50-
match product_version.starts_with("3.") {
50+
match super::uses_legacy_log4j(product_version) {
5151
true => {
5252
configs.insert(
5353
ConfigFileName::Log4j.to_string(),

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ pub fn config_file_name(config: &AnyConfig) -> ConfigFileName {
4646
}
4747
}
4848

49+
/// Whether the given Kafka version uses the legacy log4j logging framework.
50+
///
51+
/// Kafka 3.x uses log4j ([`ConfigFileName::Log4j`]); Kafka 4.0 and later use log4j2
52+
/// ([`ConfigFileName::Log4j2`]). This is the single source of truth for that decision,
53+
/// used both when rendering the log config file and when selecting the JVM option that
54+
/// points at it.
55+
pub fn uses_legacy_log4j(product_version: &str) -> bool {
56+
product_version.starts_with("3.")
57+
}
58+
4959
pub(crate) fn kraft_controllers(pod_descriptors: &[KafkaPodDescriptor]) -> Vec<String> {
5060
pod_descriptors
5161
.iter()

0 commit comments

Comments
 (0)