@@ -55,11 +55,7 @@ use stackable_operator::{
5555 } ,
5656 kvp:: { Annotation , Label , LabelError , Labels , ObjectLabels } ,
5757 logging:: controller:: ReconcilerError ,
58- product_logging:: {
59- self ,
60- framework:: LoggingError ,
61- spec:: { ContainerLogConfig , Logging } ,
62- } ,
58+ product_logging:: { self , framework:: LoggingError , spec:: ContainerLogConfig } ,
6359 role_utils:: RoleGroupRef ,
6460 shared:: time:: Duration ,
6561 status:: condition:: {
@@ -71,14 +67,14 @@ use stackable_operator::{
7167use strum:: { EnumDiscriminants , IntoStaticStr } ;
7268
7369use crate :: {
74- config ,
70+ controller :: build :: config_map ,
7571 controller_commons:: { self , CONFIG_VOLUME_NAME , LOG_CONFIG_VOLUME_NAME , LOG_VOLUME_NAME } ,
7672 crd:: {
77- self , AIRFLOW_CONFIG_FILENAME , APP_NAME , AirflowClusterStatus , AirflowConfig ,
78- AirflowExecutor , AirflowExecutorCommonConfiguration , AirflowRole , CONFIG_PATH , Container ,
79- ExecutorConfig , HTTP_PORT , HTTP_PORT_NAME , LISTENER_VOLUME_DIR , LISTENER_VOLUME_NAME ,
80- LOG_CONFIG_DIR , METRICS_PORT , METRICS_PORT_NAME , OPERATOR_NAME , STACKABLE_LOG_DIR ,
81- TEMPLATE_LOCATION , TEMPLATE_NAME , TEMPLATE_VOLUME_NAME ,
73+ self , APP_NAME , AirflowClusterStatus , AirflowConfig , AirflowExecutor ,
74+ AirflowExecutorCommonConfiguration , AirflowRole , CONFIG_PATH , Container , ExecutorConfig ,
75+ HTTP_PORT , HTTP_PORT_NAME , LISTENER_VOLUME_DIR , LISTENER_VOLUME_NAME , LOG_CONFIG_DIR ,
76+ METRICS_PORT , METRICS_PORT_NAME , OPERATOR_NAME , STACKABLE_LOG_DIR , TEMPLATE_LOCATION ,
77+ TEMPLATE_NAME , TEMPLATE_VOLUME_NAME ,
8278 authentication:: {
8379 AirflowAuthenticationClassResolved , AirflowClientAuthenticationDetailsResolved ,
8480 } ,
@@ -96,7 +92,6 @@ use crate::{
9692 } ,
9793 pdb:: add_pdbs,
9894 } ,
99- product_logging:: extend_config_map_with_log_config,
10095 service:: {
10196 build_rolegroup_headless_service, build_rolegroup_metrics_service,
10297 stateful_set_service_name,
@@ -157,16 +152,9 @@ pub enum Error {
157152 source : stackable_operator:: commons:: rbac:: Error ,
158153 } ,
159154
160- #[ snafu( display( "failed to build webserver config for {rolegroup}" ) ) ]
161- BuildWebserverConfig {
162- source : config:: webserver_config:: Error ,
163- rolegroup : RoleGroupRef < v1alpha2:: AirflowCluster > ,
164- } ,
165-
166- #[ snafu( display( "failed to build ConfigMap for {rolegroup}" ) ) ]
167- BuildRoleGroupConfig {
168- source : stackable_operator:: builder:: configmap:: Error ,
169- rolegroup : RoleGroupRef < v1alpha2:: AirflowCluster > ,
155+ #[ snafu( display( "failed to build rolegroup ConfigMap" ) ) ]
156+ BuildConfigMap {
157+ source : crate :: controller:: build:: config_map:: Error ,
170158 } ,
171159
172160 #[ snafu( display( "failed to resolve and merge config for role and role group" ) ) ]
@@ -193,12 +181,6 @@ pub enum Error {
193181 #[ snafu( display( "vector agent is enabled but vector aggregator ConfigMap is missing" ) ) ]
194182 VectorAggregatorConfigMapMissing ,
195183
196- #[ snafu( display( "failed to add the logging configuration to the ConfigMap [{cm_name}]" ) ) ]
197- InvalidLoggingConfig {
198- source : crate :: product_logging:: Error ,
199- cm_name : String ,
200- } ,
201-
202184 #[ snafu( display( "failed to update status" ) ) ]
203185 ApplyStatus {
204186 source : stackable_operator:: client:: Error ,
@@ -558,7 +540,7 @@ pub async fn reconcile_airflow(
558540 rolegroup : rolegroup. clone ( ) ,
559541 } ) ?;
560542
561- let rg_configmap = build_rolegroup_config_map (
543+ let rg_configmap = config_map :: build_rolegroup_config_map (
562544 airflow,
563545 & validated. image ,
564546 & rolegroup,
@@ -567,7 +549,8 @@ pub async fn reconcile_airflow(
567549 & validated. authorization_config ,
568550 & validated_rg_config. merged_config . logging ,
569551 & Container :: Airflow ,
570- ) ?;
552+ )
553+ . context ( BuildConfigMapSnafu ) ?;
571554 cluster_resources
572555 . add ( client, rg_configmap)
573556 . await
@@ -643,7 +626,7 @@ async fn build_executor_template(
643626 role_group : "kubernetes" . into ( ) ,
644627 } ;
645628
646- let rg_configmap = build_rolegroup_config_map (
629+ let rg_configmap = config_map :: build_rolegroup_config_map (
647630 airflow,
648631 resolved_product_image,
649632 & rolegroup,
@@ -652,7 +635,8 @@ async fn build_executor_template(
652635 authorization_config,
653636 & merged_executor_config. logging ,
654637 & Container :: Base ,
655- ) ?;
638+ )
639+ . context ( BuildConfigMapSnafu ) ?;
656640 cluster_resources
657641 . add ( client, rg_configmap)
658642 . await
@@ -699,68 +683,6 @@ async fn build_executor_template(
699683 Ok ( ( ) )
700684}
701685
702- /// The rolegroup [`ConfigMap`] configures the rolegroup based on the configuration given by the administrator
703- #[ allow( clippy:: too_many_arguments) ]
704- fn build_rolegroup_config_map (
705- airflow : & v1alpha2:: AirflowCluster ,
706- resolved_product_image : & ResolvedProductImage ,
707- rolegroup : & RoleGroupRef < v1alpha2:: AirflowCluster > ,
708- config_file_overrides : & BTreeMap < String , String > ,
709- authentication_config : & AirflowClientAuthenticationDetailsResolved ,
710- authorization_config : & AirflowAuthorizationResolved ,
711- logging : & Logging < Container > ,
712- container : & Container ,
713- ) -> Result < ConfigMap , Error > {
714- let config_file = config:: webserver_config:: build (
715- authentication_config,
716- authorization_config,
717- & resolved_product_image. product_version ,
718- config_file_overrides,
719- )
720- . with_context ( |_| BuildWebserverConfigSnafu {
721- rolegroup : rolegroup. clone ( ) ,
722- } ) ?;
723-
724- let mut cm_builder = ConfigMapBuilder :: new ( ) ;
725-
726- cm_builder
727- . metadata (
728- ObjectMetaBuilder :: new ( )
729- . name_and_namespace ( airflow)
730- . name ( rolegroup. object_name ( ) )
731- . ownerreference_from_resource ( airflow, None , Some ( true ) )
732- . context ( ObjectMissingMetadataForOwnerRefSnafu ) ?
733- . with_recommended_labels ( & build_recommended_labels (
734- airflow,
735- AIRFLOW_CONTROLLER_NAME ,
736- & resolved_product_image. app_version_label_value ,
737- & rolegroup. role ,
738- & rolegroup. role_group ,
739- ) )
740- . context ( ObjectMetaSnafu ) ?
741- . build ( ) ,
742- )
743- . add_data ( AIRFLOW_CONFIG_FILENAME , config_file) ;
744-
745- extend_config_map_with_log_config (
746- rolegroup,
747- logging,
748- container,
749- & Container :: Vector ,
750- & mut cm_builder,
751- resolved_product_image,
752- )
753- . context ( InvalidLoggingConfigSnafu {
754- cm_name : rolegroup. object_name ( ) ,
755- } ) ?;
756-
757- cm_builder
758- . build ( )
759- . with_context ( |_| BuildRoleGroupConfigSnafu {
760- rolegroup : rolegroup. clone ( ) ,
761- } )
762- }
763-
764686fn build_rolegroup_metadata (
765687 airflow : & v1alpha2:: AirflowCluster ,
766688 resolved_product_image : & & ResolvedProductImage ,
0 commit comments