@@ -15,8 +15,8 @@ use stackable_operator::{
1515
1616use crate :: {
1717 crd:: {
18- AirflowExecutor , AirflowRole , ExecutorConfig , LOG_CONFIG_DIR , STACKABLE_LOG_DIR ,
19- TEMPLATE_LOCATION , TEMPLATE_NAME ,
18+ AIRFLOW_DAGS_FOLDER , AirflowExecutor , AirflowRole , ExecutorConfig , LOG_CONFIG_DIR ,
19+ STACKABLE_LOG_DIR , TEMPLATE_LOCATION , TEMPLATE_NAME ,
2020 authentication:: {
2121 AirflowAuthenticationClassResolved , AirflowClientAuthenticationDetailsResolved ,
2222 } ,
@@ -154,12 +154,11 @@ pub fn build_airflow_statefulset_envs(
154154 ) ;
155155 }
156156
157- let dags_folder = get_dags_folder ( git_sync_resources) ;
158157 env. insert (
159158 AIRFLOW_CORE_DAGS_FOLDER . into ( ) ,
160159 EnvVar {
161160 name : AIRFLOW_CORE_DAGS_FOLDER . into ( ) ,
162- value : Some ( dags_folder ) ,
161+ value : Some ( AIRFLOW_DAGS_FOLDER . to_owned ( ) ) ,
163162 ..Default :: default ( )
164163 } ,
165164 ) ;
@@ -288,23 +287,28 @@ pub fn build_airflow_statefulset_envs(
288287 Ok ( transform_map_to_vec ( env) )
289288}
290289
291- pub fn get_dags_folder ( git_sync_resources : & git_sync:: v1alpha1:: GitSyncResources ) -> String {
292- let git_sync_count = git_sync_resources. git_content_folders . len ( ) ;
293- if git_sync_count > 1 {
294- tracing:: warn!(
295- "There are {git_sync_count} git-sync entries: Only the first one will be considered." ,
296- ) ;
297- }
298-
290+ pub fn get_dags_folder ( git_sync_resources : & git_sync:: v1alpha1:: GitSyncResources ) -> Vec < String > {
291+ // let git_sync_count = git_sync_resources.git_content_folders.len();
292+ // if git_sync_count > 1 {
293+ // tracing::warn!(
294+ // "There are {git_sync_count} git-sync entries: Only the first one will be considered.",
295+ // );
296+ // }
297+ let mut git_folders = Vec :: < String > :: new ( ) ;
299298 // If DAG provisioning via git-sync is not configured, set a default value
300299 // so that PYTHONPATH can refer to it. N.B. nested variables need to be
301300 // resolved, so that /stackable/airflow is used instead of $AIRFLOW_HOME.
302301 // see https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#dags-folder
303- git_sync_resources
304- . git_content_folders_as_string ( )
305- . first ( )
306- . cloned ( )
307- . unwrap_or ( "/stackable/airflow/dags" . to_string ( ) )
302+ // git_sync_resources
303+ // .git_content_folders_as_string()
304+ // .first()
305+ // .cloned()
306+ // .unwrap_or("/stackable/airflow/dags".to_string())
307+ // TODO: Might need check weather path is correct.
308+ for folder in git_sync_resources. git_content_folders_as_string ( ) {
309+ git_folders. push ( folder)
310+ }
311+ git_folders
308312}
309313
310314// This set of environment variables is a standard set that is not dependent on any
@@ -314,7 +318,17 @@ fn static_envs(
314318) -> BTreeMap < String , EnvVar > {
315319 let mut env: BTreeMap < String , EnvVar > = BTreeMap :: new ( ) ;
316320
317- let dags_folder = get_dags_folder ( git_sync_resources) ;
321+ let dags_folders = get_dags_folder ( git_sync_resources) ;
322+ let mut dag_python_path = String :: new ( ) ;
323+
324+ // TODO: Might be there is a better solution to this
325+ for ( i, dags_folder) in dags_folders. iter ( ) . enumerate ( ) {
326+ dag_python_path. push_str ( dags_folder) ;
327+ // Can't append ":" if it's last entry
328+ if i != ( dags_folders. len ( ) - 1 ) {
329+ dag_python_path. push_str ( ":" ) ;
330+ }
331+ }
318332
319333 env. insert (
320334 PYTHONPATH . into ( ) ,
@@ -323,7 +337,7 @@ fn static_envs(
323337 // dependencies can be found: this must be the actual path and not a variable.
324338 // Also include the airflow site-packages by default (for airflow and kubernetes classes etc.)
325339 name : PYTHONPATH . into ( ) ,
326- value : Some ( format ! ( "{LOG_CONFIG_DIR}:{dags_folder }" ) ) ,
340+ value : Some ( format ! ( "{LOG_CONFIG_DIR}:{dag_python_path }" ) ) ,
327341 ..Default :: default ( )
328342 } ,
329343 ) ;
@@ -407,12 +421,11 @@ pub fn build_airflow_template_envs(
407421
408422 // the config map also requires the dag-folder location as this will be passed on
409423 // to the pods started by airflow.
410- let dags_folder = get_dags_folder ( git_sync_resources) ;
411424 env. insert (
412425 AIRFLOW_CORE_DAGS_FOLDER . into ( ) ,
413426 EnvVar {
414427 name : AIRFLOW_CORE_DAGS_FOLDER . into ( ) ,
415- value : Some ( dags_folder ) ,
428+ value : Some ( AIRFLOW_DAGS_FOLDER . to_owned ( ) ) ,
416429 ..Default :: default ( )
417430 } ,
418431 ) ;
0 commit comments