@@ -7,16 +7,21 @@ use snafu::{ResultExt, Snafu};
77use stackable_operator:: {
88 builder:: { configmap:: ConfigMapBuilder , meta:: ObjectMetaBuilder } ,
99 k8s_openapi:: api:: core:: v1:: ConfigMap ,
10- product_logging:: spec:: Logging ,
10+ product_logging:: {
11+ self ,
12+ spec:: { ContainerLogConfig , ContainerLogConfigChoice , Logging } ,
13+ } ,
1114 role_utils:: RoleGroupRef ,
1215} ;
1316
1417use crate :: {
1518 airflow_controller:: AIRFLOW_CONTROLLER_NAME ,
1619 config:: webserver_config,
1720 controller:: validate:: ValidatedAirflowCluster ,
18- crd:: { AIRFLOW_CONFIG_FILENAME , Container , build_recommended_labels, v1alpha2} ,
19- product_logging:: extend_config_map_with_log_config,
21+ crd:: {
22+ AIRFLOW_CONFIG_FILENAME , Container , STACKABLE_LOG_DIR , build_recommended_labels, v1alpha2,
23+ } ,
24+ product_logging:: { LOG_CONFIG_FILE , create_airflow_config} ,
2025} ;
2126
2227#[ derive( Snafu , Debug ) ]
@@ -91,14 +96,33 @@ pub fn build_rolegroup_config_map(
9196 )
9297 . add_data ( AIRFLOW_CONFIG_FILENAME , config_file) ;
9398
94- extend_config_map_with_log_config (
95- rolegroup,
96- logging,
97- container,
98- & Container :: Vector ,
99- & mut cm_builder,
100- & validated_cluster. image ,
101- ) ;
99+ // Log config for the main container, when it uses an Automatic log config.
100+ if let Some ( ContainerLogConfig {
101+ choice : Some ( ContainerLogConfigChoice :: Automatic ( log_config) ) ,
102+ } ) = logging. containers . get ( container)
103+ {
104+ let log_dir = format ! ( "{STACKABLE_LOG_DIR}/{container}" ) ;
105+ cm_builder. add_data (
106+ LOG_CONFIG_FILE ,
107+ create_airflow_config ( log_config, & log_dir, & validated_cluster. image ) ,
108+ ) ;
109+ }
110+
111+ // Vector agent config, when enabled.
112+ if logging. enable_vector_agent {
113+ let vector_log_config = if let Some ( ContainerLogConfig {
114+ choice : Some ( ContainerLogConfigChoice :: Automatic ( log_config) ) ,
115+ } ) = logging. containers . get ( & Container :: Vector )
116+ {
117+ Some ( log_config)
118+ } else {
119+ None
120+ } ;
121+ cm_builder. add_data (
122+ product_logging:: framework:: VECTOR_CONFIG_FILE ,
123+ product_logging:: framework:: create_vector_config ( rolegroup, vector_log_config) ,
124+ ) ;
125+ }
102126
103127 cm_builder. build ( ) . with_context ( |_| BuildConfigMapSnafu {
104128 rolegroup : rolegroup. clone ( ) ,
0 commit comments