|
1 | 1 | //! Ensures that `Pod`s are configured and running for each [`v1alpha2::AirflowCluster`] |
2 | 2 | use std::{ |
3 | | - collections::{BTreeSet, HashMap}, |
| 3 | + collections::{BTreeMap, BTreeSet, HashMap}, |
4 | 4 | sync::Arc, |
5 | 5 | }; |
6 | 6 |
|
@@ -67,20 +67,18 @@ use stackable_operator::{ |
67 | 67 | use strum::{EnumDiscriminants, IntoStaticStr}; |
68 | 68 |
|
69 | 69 | use crate::{ |
70 | | - controller::{ |
71 | | - build::config_map, |
72 | | - validate::{ValidatedAirflowCluster, ValidatedRoleGroupConfig}, |
73 | | - }, |
| 70 | + controller::build::config_map, |
74 | 71 | controller_commons::{self, CONFIG_VOLUME_NAME, LOG_CONFIG_VOLUME_NAME, LOG_VOLUME_NAME}, |
75 | 72 | crd::{ |
76 | | - self, APP_NAME, AirflowClusterStatus, AirflowConfigOverrides, AirflowExecutor, |
77 | | - AirflowExecutorCommonConfiguration, AirflowRole, CONFIG_PATH, Container, ExecutorConfig, |
78 | | - HTTP_PORT, HTTP_PORT_NAME, LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME, LOG_CONFIG_DIR, |
79 | | - METRICS_PORT, METRICS_PORT_NAME, OPERATOR_NAME, STACKABLE_LOG_DIR, TEMPLATE_LOCATION, |
80 | | - TEMPLATE_NAME, TEMPLATE_VOLUME_NAME, |
| 73 | + self, APP_NAME, AirflowClusterStatus, AirflowConfig, AirflowConfigOverrides, |
| 74 | + AirflowExecutor, AirflowExecutorCommonConfiguration, AirflowRole, CONFIG_PATH, Container, |
| 75 | + ExecutorConfig, HTTP_PORT, HTTP_PORT_NAME, LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME, |
| 76 | + LOG_CONFIG_DIR, METRICS_PORT, METRICS_PORT_NAME, OPERATOR_NAME, STACKABLE_LOG_DIR, |
| 77 | + TEMPLATE_LOCATION, TEMPLATE_NAME, TEMPLATE_VOLUME_NAME, |
81 | 78 | authentication::{ |
82 | 79 | AirflowAuthenticationClassResolved, AirflowClientAuthenticationDetailsResolved, |
83 | 80 | }, |
| 81 | + authorization::AirflowAuthorizationResolved, |
84 | 82 | build_recommended_labels, |
85 | 83 | internal_secret::{ |
86 | 84 | FERNET_KEY_SECRET_KEY, INTERNAL_SECRET_SECRET_KEY, JWT_SECRET_SECRET_KEY, |
@@ -110,6 +108,41 @@ pub struct Ctx { |
110 | 108 | pub operator_environment: OperatorEnvironmentOptions, |
111 | 109 | } |
112 | 110 |
|
| 111 | +/// Per-role configuration extracted during validation. |
| 112 | +#[derive(Clone, Debug)] |
| 113 | +pub struct ValidatedRoleConfig { |
| 114 | + pub pdb: Option<stackable_operator::commons::pdb::PdbConfig>, |
| 115 | + pub listener_class: Option<String>, |
| 116 | + pub group_listener_name: Option<String>, |
| 117 | +} |
| 118 | + |
| 119 | +/// Per-rolegroup configuration: the merged CRD config plus overrides. |
| 120 | +/// |
| 121 | +/// `config_overrides` is kept as the typed [`AirflowConfigOverrides`] (role-group merged over |
| 122 | +/// role); it is flattened into the rendered config file later, in the build step. This mirrors |
| 123 | +/// hdfs-operator. `env_overrides` is already a flat map. |
| 124 | +#[derive(Clone, Debug)] |
| 125 | +pub struct ValidatedRoleGroupConfig { |
| 126 | + pub merged_config: AirflowConfig, |
| 127 | + pub config_overrides: AirflowConfigOverrides, |
| 128 | + pub env_overrides: HashMap<String, String>, |
| 129 | + pub replicas: Option<u16>, |
| 130 | + pub pod_overrides: PodTemplateSpec, |
| 131 | +} |
| 132 | + |
| 133 | +/// The validated cluster: proves that config merging succeeded for every role and |
| 134 | +/// role group before any resources are created. It also carries the dereferenced |
| 135 | +/// external references, so every downstream build step reads them from here. |
| 136 | +#[derive(Clone, Debug)] |
| 137 | +pub struct ValidatedAirflowCluster { |
| 138 | + pub image: ResolvedProductImage, |
| 139 | + pub role_groups: BTreeMap<AirflowRole, BTreeMap<String, ValidatedRoleGroupConfig>>, |
| 140 | + pub role_configs: BTreeMap<AirflowRole, ValidatedRoleConfig>, |
| 141 | + pub executor: AirflowExecutor, |
| 142 | + pub authentication_config: AirflowClientAuthenticationDetailsResolved, |
| 143 | + pub authorization_config: AirflowAuthorizationResolved, |
| 144 | +} |
| 145 | + |
113 | 146 | #[derive(Snafu, Debug, EnumDiscriminants)] |
114 | 147 | #[strum_discriminants(derive(IntoStaticStr))] |
115 | 148 | pub enum Error { |
|
0 commit comments