@@ -3,6 +3,7 @@ use std::fmt::{Display, Write};
33use snafu:: Snafu ;
44use stackable_operator:: {
55 builder:: configmap:: ConfigMapBuilder ,
6+ commons:: product_image_selection:: ResolvedProductImage ,
67 kube:: Resource ,
78 product_logging:: {
89 self ,
@@ -43,6 +44,7 @@ pub fn extend_config_map_with_log_config<C, K>(
4344 main_container : & C ,
4445 vector_container : & C ,
4546 cm_builder : & mut ConfigMapBuilder ,
47+ resolved_product_image : & ResolvedProductImage ,
4648) -> Result < ( ) >
4749where
4850 C : Clone + Ord + Display ,
5355 } ) = logging. containers . get ( main_container)
5456 {
5557 let log_dir = format ! ( "{STACKABLE_LOG_DIR}/{main_container}" ) ;
56- cm_builder. add_data ( LOG_CONFIG_FILE , create_airflow_config ( log_config, & log_dir) ) ;
58+ cm_builder. add_data (
59+ LOG_CONFIG_FILE ,
60+ create_airflow_config ( log_config, & log_dir, resolved_product_image) ,
61+ ) ;
5762 }
5863
5964 let vector_log_config = if let Some ( ContainerLogConfig {
7580 Ok ( ( ) )
7681}
7782
78- fn create_airflow_config ( log_config : & AutomaticContainerLogConfig , log_dir : & str ) -> String {
83+ fn create_airflow_config (
84+ log_config : & AutomaticContainerLogConfig ,
85+ log_dir : & str ,
86+ resolved_product_image : & ResolvedProductImage ,
87+ ) -> String {
7988 let loggers_config = log_config
8089 . loggers
8190 . iter ( )
@@ -92,18 +101,28 @@ LOGGING_CONFIG['loggers']['{name}']['level'] = {level}
92101 output
93102 } ) ;
94103
104+ let remote_task_log = if resolved_product_image. product_version . starts_with ( "2." ) {
105+ ""
106+ } else {
107+ "
108+ # This will cause the relevant RemoteLogIO handler to be initialized
109+ REMOTE_TASK_LOG = airflow_local_settings.REMOTE_TASK_LOG
110+ log = logging.getLogger(__name__)
111+ log.info('Custom logging remote task log %s', REMOTE_TASK_LOG)
112+ "
113+ } ;
114+
95115 format ! (
96116 "\
97117 import logging
98118import os
99119from copy import deepcopy
100- from airflow.config_templates.airflow_local_settings import DEFAULT_LOGGING_CONFIG
120+ from airflow.config_templates import airflow_local_settings
101121
102122os.makedirs('{log_dir}', exist_ok=True)
103123
104- LOGGING_CONFIG = deepcopy(DEFAULT_LOGGING_CONFIG)
105-
106- REMOTE_TASK_LOG = None
124+ LOGGING_CONFIG = deepcopy(airflow_local_settings.DEFAULT_LOGGING_CONFIG)
125+ {remote_task_log}
107126
108127LOGGING_CONFIG.setdefault('loggers', {{}})
109128for logger_name, logger_config in LOGGING_CONFIG['loggers'].items():
0 commit comments