11use stackable_operator:: {
2- builder:: configmap:: ConfigMapBuilder ,
32 memory:: { BinaryMultiple , MemoryQuantity } ,
43 product_logging:: {
54 self ,
@@ -10,10 +9,7 @@ use stackable_operator::{
109 role_utils:: RoleGroupRef ,
1110} ;
1211
13- use crate :: {
14- controller:: build:: properties:: ConfigFileName ,
15- crd:: { Container , v1alpha1} ,
16- } ;
12+ use crate :: crd:: { Container , v1alpha1} ;
1713
1814pub const STACKABLE_LOG_DIR : & str = "/stackable/log" ;
1915pub const MAX_HBASE_LOG_FILES_SIZE : MemoryQuantity = MemoryQuantity {
@@ -24,34 +20,42 @@ pub const MAX_HBASE_LOG_FILES_SIZE: MemoryQuantity = MemoryQuantity {
2420const CONSOLE_CONVERSION_PATTERN : & str = "%d{ISO8601} %-5p [%t] %c{2}: %.1000m%n" ;
2521const HBASE_LOG4J2_FILE : & str = "hbase.log4j2.xml" ;
2622
27- /// Extend the role group ConfigMap with logging and Vector configurations
28- pub fn extend_role_group_config_map (
23+ /// Renders `log4j2.properties` for the HBase container.
24+ ///
25+ /// Returns `None` when the HBase container does not use the operator's automatic logging
26+ /// configuration (e.g. a custom log ConfigMap is referenced instead), in which case no
27+ /// `log4j2.properties` should be added to the rolegroup `ConfigMap`.
28+ pub fn build_log4j2 ( logging : & Logging < Container > ) -> Option < String > {
29+ match logging. containers . get ( & Container :: Hbase ) {
30+ Some ( ContainerLogConfig {
31+ choice : Some ( ContainerLogConfigChoice :: Automatic ( log_config) ) ,
32+ } ) => Some ( log4j_config ( log_config) ) ,
33+ _ => None ,
34+ }
35+ }
36+
37+ /// Renders the Vector agent config (`vector.yaml`).
38+ ///
39+ /// Returns `None` when the Vector agent is disabled for this role group.
40+ pub fn build_vector_config (
2941 rolegroup : & RoleGroupRef < v1alpha1:: HbaseCluster > ,
3042 logging : & Logging < Container > ,
31- cm_builder : & mut ConfigMapBuilder ,
32- ) {
33- if let Some ( ContainerLogConfig {
34- choice : Some ( ContainerLogConfigChoice :: Automatic ( log_config) ) ,
35- } ) = logging. containers . get ( & Container :: Hbase )
36- {
37- cm_builder. add_data ( ConfigFileName :: Log4j2 . to_string ( ) , log4j_config ( log_config) ) ;
43+ ) -> Option < String > {
44+ if !logging. enable_vector_agent {
45+ return None ;
3846 }
3947
40- let vector_log_config = if let Some ( ContainerLogConfig {
41- choice : Some ( ContainerLogConfigChoice :: Automatic ( log_config) ) ,
42- } ) = logging. containers . get ( & Container :: Vector )
43- {
44- Some ( log_config)
45- } else {
46- None
48+ let vector_log_config = match logging. containers . get ( & Container :: Vector ) {
49+ Some ( ContainerLogConfig {
50+ choice : Some ( ContainerLogConfigChoice :: Automatic ( log_config) ) ,
51+ } ) => Some ( log_config) ,
52+ _ => None ,
4753 } ;
4854
49- if logging. enable_vector_agent {
50- cm_builder. add_data (
51- product_logging:: framework:: VECTOR_CONFIG_FILE ,
52- product_logging:: framework:: create_vector_config ( rolegroup, vector_log_config) ,
53- ) ;
54- }
55+ Some ( product_logging:: framework:: create_vector_config (
56+ rolegroup,
57+ vector_log_config,
58+ ) )
5559}
5660
5761fn log4j_config ( log_config : & AutomaticContainerLogConfig ) -> String {
0 commit comments