1- //! Ensures that `Pod`s are configured and running for each [`AirflowCluster`]
1+ //! Ensures that `Pod`s are configured and running for each [`v1alpha1:: AirflowCluster`]
22use std:: {
33 collections:: { BTreeMap , BTreeSet , HashMap } ,
44 io:: Write ,
@@ -13,18 +13,6 @@ use product_config::{
1313 ProductConfigManager ,
1414} ;
1515use snafu:: { OptionExt , ResultExt , Snafu } ;
16- use stackable_airflow_crd:: {
17- authentication:: {
18- AirflowAuthenticationClassResolved , AirflowClientAuthenticationDetailsResolved ,
19- } ,
20- build_recommended_labels,
21- git_sync:: GitSync ,
22- AirflowCluster , AirflowClusterStatus , AirflowConfig , AirflowConfigOptions , AirflowExecutor ,
23- AirflowRole , Container , ExecutorConfig , ExecutorConfigFragment , AIRFLOW_CONFIG_FILENAME ,
24- AIRFLOW_UID , APP_NAME , CONFIG_PATH , GIT_CONTENT , GIT_ROOT , GIT_SYNC_NAME , LOG_CONFIG_DIR ,
25- OPERATOR_NAME , STACKABLE_LOG_DIR , TEMPLATE_CONFIGMAP_NAME , TEMPLATE_LOCATION , TEMPLATE_NAME ,
26- TEMPLATE_VOLUME_NAME ,
27- } ;
2816use stackable_operator:: {
2917 builder:: {
3018 self ,
@@ -86,6 +74,18 @@ use strum::{EnumDiscriminants, IntoEnumIterator, IntoStaticStr};
8674use crate :: {
8775 config:: { self , PYTHON_IMPORTS } ,
8876 controller_commons:: { self , CONFIG_VOLUME_NAME , LOG_CONFIG_VOLUME_NAME , LOG_VOLUME_NAME } ,
77+ crd:: {
78+ self ,
79+ authentication:: {
80+ AirflowAuthenticationClassResolved , AirflowClientAuthenticationDetailsResolved ,
81+ } ,
82+ build_recommended_labels,
83+ git_sync:: { GitSync , GIT_SYNC_CONTENT , GIT_SYNC_NAME , GIT_SYNC_ROOT } ,
84+ v1alpha1, AirflowClusterStatus , AirflowConfig , AirflowConfigOptions , AirflowExecutor ,
85+ AirflowRole , Container , ExecutorConfig , ExecutorConfigFragment , AIRFLOW_CONFIG_FILENAME ,
86+ AIRFLOW_UID , APP_NAME , CONFIG_PATH , LOG_CONFIG_DIR , OPERATOR_NAME , STACKABLE_LOG_DIR ,
87+ TEMPLATE_CONFIGMAP_NAME , TEMPLATE_LOCATION , TEMPLATE_NAME , TEMPLATE_VOLUME_NAME ,
88+ } ,
8989 env_vars:: {
9090 self , build_airflow_template_envs, build_gitsync_statefulset_envs, build_gitsync_template,
9191 } ,
@@ -113,7 +113,6 @@ pub struct Ctx {
113113
114114#[ derive( Snafu , Debug , EnumDiscriminants ) ]
115115#[ strum_discriminants( derive( IntoStaticStr ) ) ]
116- #[ allow( clippy:: enum_variant_names) ]
117116pub enum Error {
118117 #[ snafu( display( "object has no namespace" ) ) ]
119118 ObjectHasNoNamespace ,
@@ -129,19 +128,19 @@ pub enum Error {
129128 #[ snafu( display( "failed to apply Service for {rolegroup}" ) ) ]
130129 ApplyRoleGroupService {
131130 source : stackable_operator:: cluster_resources:: Error ,
132- rolegroup : RoleGroupRef < AirflowCluster > ,
131+ rolegroup : RoleGroupRef < v1alpha1 :: AirflowCluster > ,
133132 } ,
134133
135134 #[ snafu( display( "failed to apply ConfigMap for {rolegroup}" ) ) ]
136135 ApplyRoleGroupConfig {
137136 source : stackable_operator:: cluster_resources:: Error ,
138- rolegroup : RoleGroupRef < AirflowCluster > ,
137+ rolegroup : RoleGroupRef < v1alpha1 :: AirflowCluster > ,
139138 } ,
140139
141140 #[ snafu( display( "failed to apply StatefulSet for {rolegroup}" ) ) ]
142141 ApplyRoleGroupStatefulSet {
143142 source : stackable_operator:: cluster_resources:: Error ,
144- rolegroup : RoleGroupRef < AirflowCluster > ,
143+ rolegroup : RoleGroupRef < v1alpha1 :: AirflowCluster > ,
145144 } ,
146145
147146 #[ snafu( display( "invalid product config" ) ) ]
@@ -192,19 +191,17 @@ pub enum Error {
192191 #[ snafu( display( "failed to build config file for {rolegroup}" ) ) ]
193192 BuildRoleGroupConfigFile {
194193 source : FlaskAppConfigWriterError ,
195- rolegroup : RoleGroupRef < AirflowCluster > ,
194+ rolegroup : RoleGroupRef < v1alpha1 :: AirflowCluster > ,
196195 } ,
197196
198197 #[ snafu( display( "failed to build ConfigMap for {rolegroup}" ) ) ]
199198 BuildRoleGroupConfig {
200199 source : stackable_operator:: builder:: configmap:: Error ,
201- rolegroup : RoleGroupRef < AirflowCluster > ,
200+ rolegroup : RoleGroupRef < v1alpha1 :: AirflowCluster > ,
202201 } ,
203202
204203 #[ snafu( display( "failed to resolve and merge config for role and role group" ) ) ]
205- FailedToResolveConfig {
206- source : stackable_airflow_crd:: Error ,
207- } ,
204+ FailedToResolveConfig { source : crd:: Error } ,
208205
209206 #[ snafu( display( "could not parse Airflow role [{role}]" ) ) ]
210207 UnidentifiedAirflowRole {
@@ -249,9 +246,7 @@ pub enum Error {
249246 } ,
250247
251248 #[ snafu( display( "failed to apply authentication configuration" ) ) ]
252- InvalidAuthenticationConfig {
253- source : stackable_airflow_crd:: authentication:: Error ,
254- } ,
249+ InvalidAuthenticationConfig { source : crd:: authentication:: Error } ,
255250
256251 #[ snafu( display( "pod template serialization" ) ) ]
257252 PodTemplateSerde { source : serde_yaml:: Error } ,
@@ -336,7 +331,7 @@ impl ReconcilerError for Error {
336331}
337332
338333pub async fn reconcile_airflow (
339- airflow : Arc < DeserializeGuard < AirflowCluster > > ,
334+ airflow : Arc < DeserializeGuard < v1alpha1 :: AirflowCluster > > ,
340335 ctx : Arc < Ctx > ,
341336) -> Result < Action > {
342337 tracing:: info!( "Starting reconcile" ) ;
@@ -558,7 +553,7 @@ pub async fn reconcile_airflow(
558553
559554#[ allow( clippy:: too_many_arguments) ]
560555async fn build_executor_template (
561- airflow : & AirflowCluster ,
556+ airflow : & v1alpha1 :: AirflowCluster ,
562557 common_config : & CommonConfiguration < ExecutorConfigFragment , GenericProductSpecificCommonConfig > ,
563558 resolved_product_image : & ResolvedProductImage ,
564559 authentication_config : & AirflowClientAuthenticationDetailsResolved ,
@@ -612,7 +607,7 @@ async fn build_executor_template(
612607/// The server-role service is the primary endpoint that should be used by clients that do not perform internal load balancing,
613608/// including targets outside the cluster.
614609fn build_role_service (
615- airflow : & AirflowCluster ,
610+ airflow : & v1alpha1 :: AirflowCluster ,
616611 resolved_product_image : & ResolvedProductImage ,
617612 role_name : & str ,
618613 port : u16 ,
@@ -674,9 +669,9 @@ fn role_port(role_name: &str) -> Option<u16> {
674669/// The rolegroup [`ConfigMap`] configures the rolegroup based on the configuration given by the administrator
675670#[ allow( clippy:: too_many_arguments) ]
676671fn build_rolegroup_config_map (
677- airflow : & AirflowCluster ,
672+ airflow : & v1alpha1 :: AirflowCluster ,
678673 resolved_product_image : & ResolvedProductImage ,
679- rolegroup : & RoleGroupRef < AirflowCluster > ,
674+ rolegroup : & RoleGroupRef < v1alpha1 :: AirflowCluster > ,
680675 rolegroup_config : & HashMap < PropertyNameKind , BTreeMap < String , String > > ,
681676 authentication_config : & AirflowClientAuthenticationDetailsResolved ,
682677 logging : & Logging < Container > ,
@@ -760,9 +755,9 @@ fn build_rolegroup_config_map(
760755///
761756/// This is mostly useful for internal communication between peers, or for clients that perform client-side load balancing.
762757fn build_rolegroup_service (
763- airflow : & AirflowCluster ,
758+ airflow : & v1alpha1 :: AirflowCluster ,
764759 resolved_product_image : & ResolvedProductImage ,
765- rolegroup : & RoleGroupRef < AirflowCluster > ,
760+ rolegroup : & RoleGroupRef < v1alpha1 :: AirflowCluster > ,
766761) -> Result < Service > {
767762 let mut ports = vec ! [ ServicePort {
768763 name: Some ( METRICS_PORT_NAME . into( ) ) ,
@@ -807,9 +802,9 @@ fn build_rolegroup_service(
807802}
808803
809804fn build_rolegroup_metadata (
810- airflow : & AirflowCluster ,
805+ airflow : & v1alpha1 :: AirflowCluster ,
811806 resolved_product_image : & & ResolvedProductImage ,
812- rolegroup : & & RoleGroupRef < AirflowCluster > ,
807+ rolegroup : & & RoleGroupRef < v1alpha1 :: AirflowCluster > ,
813808 prometheus_label : Label ,
814809) -> Result < ObjectMeta , Error > {
815810 let metadata = ObjectMetaBuilder :: new ( )
@@ -835,10 +830,10 @@ fn build_rolegroup_metadata(
835830/// The [`Pod`](`stackable_operator::k8s_openapi::api::core::v1::Pod`)s are accessible through the corresponding [`Service`] (from [`build_rolegroup_service`]).
836831#[ allow( clippy:: too_many_arguments) ]
837832fn build_server_rolegroup_statefulset (
838- airflow : & AirflowCluster ,
833+ airflow : & v1alpha1 :: AirflowCluster ,
839834 resolved_product_image : & ResolvedProductImage ,
840835 airflow_role : & AirflowRole ,
841- rolegroup_ref : & RoleGroupRef < AirflowCluster > ,
836+ rolegroup_ref : & RoleGroupRef < v1alpha1 :: AirflowCluster > ,
842837 rolegroup_config : & HashMap < PropertyNameKind , BTreeMap < String , String > > ,
843838 authentication_config : & AirflowClientAuthenticationDetailsResolved ,
844839 service_account : & ServiceAccount ,
@@ -1008,7 +1003,7 @@ fn build_server_rolegroup_statefulset(
10081003 ) ?;
10091004
10101005 pb. add_volume (
1011- VolumeBuilder :: new ( GIT_CONTENT )
1006+ VolumeBuilder :: new ( GIT_SYNC_CONTENT )
10121007 . empty_dir ( EmptyDirVolumeSource :: default ( ) )
10131008 . build ( ) ,
10141009 )
@@ -1116,14 +1111,14 @@ fn build_logging_container(
11161111
11171112#[ allow( clippy:: too_many_arguments) ]
11181113fn build_executor_template_config_map (
1119- airflow : & AirflowCluster ,
1114+ airflow : & v1alpha1 :: AirflowCluster ,
11201115 resolved_product_image : & ResolvedProductImage ,
11211116 authentication_config : & AirflowClientAuthenticationDetailsResolved ,
11221117 sa_name : & str ,
11231118 merged_executor_config : & ExecutorConfig ,
11241119 env_overrides : & HashMap < String , String > ,
11251120 pod_overrides : & PodTemplateSpec ,
1126- rolegroup_ref : & RoleGroupRef < AirflowCluster > ,
1121+ rolegroup_ref : & RoleGroupRef < v1alpha1 :: AirflowCluster > ,
11271122) -> Result < ConfigMap > {
11281123 let mut pb = PodBuilder :: new ( ) ;
11291124 let pb_metadata = ObjectMetaBuilder :: new ( )
@@ -1203,7 +1198,7 @@ fn build_executor_template_config_map(
12031198 airflow. volume_mounts ( ) ,
12041199 ) ?;
12051200 pb. add_volume (
1206- VolumeBuilder :: new ( GIT_CONTENT )
1201+ VolumeBuilder :: new ( GIT_SYNC_CONTENT )
12071202 . empty_dir ( EmptyDirVolumeSource :: default ( ) )
12081203 . build ( ) ,
12091204 )
@@ -1275,7 +1270,7 @@ fn build_gitsync_container(
12751270 "-c" . to_string( ) ,
12761271 ] )
12771272 . args ( vec ! [ gitsync. get_args( one_time) . join( "\n " ) ] )
1278- . add_volume_mount ( GIT_CONTENT , GIT_ROOT )
1273+ . add_volume_mount ( GIT_SYNC_CONTENT , GIT_SYNC_ROOT )
12791274 . context ( AddVolumeMountSnafu ) ?
12801275 . add_volume_mounts ( volume_mounts)
12811276 . context ( AddVolumeMountSnafu ) ?
@@ -1292,7 +1287,7 @@ fn build_gitsync_container(
12921287}
12931288
12941289pub fn error_policy (
1295- _obj : Arc < DeserializeGuard < AirflowCluster > > ,
1290+ _obj : Arc < DeserializeGuard < v1alpha1 :: AirflowCluster > > ,
12961291 error : & Error ,
12971292 _ctx : Arc < Ctx > ,
12981293) -> Action {
0 commit comments