Skip to content

Commit 598be32

Browse files
committed
move remaining validated structs to controller
1 parent 85fdfae commit 598be32

3 files changed

Lines changed: 52 additions & 54 deletions

File tree

rust/operator-binary/src/airflow_controller.rs

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Ensures that `Pod`s are configured and running for each [`v1alpha2::AirflowCluster`]
22
use std::{
3-
collections::{BTreeSet, HashMap},
3+
collections::{BTreeMap, BTreeSet, HashMap},
44
sync::Arc,
55
};
66

@@ -67,20 +67,18 @@ use stackable_operator::{
6767
use strum::{EnumDiscriminants, IntoStaticStr};
6868

6969
use crate::{
70-
controller::{
71-
build::config_map,
72-
validate::{ValidatedAirflowCluster, ValidatedRoleGroupConfig},
73-
},
70+
controller::build::config_map,
7471
controller_commons::{self, CONFIG_VOLUME_NAME, LOG_CONFIG_VOLUME_NAME, LOG_VOLUME_NAME},
7572
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,
8178
authentication::{
8279
AirflowAuthenticationClassResolved, AirflowClientAuthenticationDetailsResolved,
8380
},
81+
authorization::AirflowAuthorizationResolved,
8482
build_recommended_labels,
8583
internal_secret::{
8684
FERNET_KEY_SECRET_KEY, INTERNAL_SECRET_SECRET_KEY, JWT_SECRET_SECRET_KEY,
@@ -110,6 +108,41 @@ pub struct Ctx {
110108
pub operator_environment: OperatorEnvironmentOptions,
111109
}
112110

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+
113146
#[derive(Snafu, Debug, EnumDiscriminants)]
114147
#[strum_discriminants(derive(IntoStaticStr))]
115148
pub enum Error {

rust/operator-binary/src/controller/build/config_map.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ use stackable_operator::{
1515
};
1616

1717
use crate::{
18-
airflow_controller::AIRFLOW_CONTROLLER_NAME,
18+
airflow_controller::{AIRFLOW_CONTROLLER_NAME, ValidatedAirflowCluster},
1919
config::webserver_config,
20-
controller::validate::ValidatedAirflowCluster,
2120
crd::{
2221
AIRFLOW_CONFIG_FILENAME, AirflowConfigOverrides, Container, STACKABLE_LOG_DIR,
2322
build_recommended_labels, v1alpha2,

rust/operator-binary/src/controller/validate.rs

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
use std::collections::{BTreeMap, HashMap};
1+
use std::collections::BTreeMap;
22

33
use snafu::{ResultExt, Snafu};
44
use stackable_operator::{
5-
commons::product_image_selection::{self, ResolvedProductImage},
5+
commons::product_image_selection,
66
config::fragment,
7-
k8s_openapi::api::core::v1::PodTemplateSpec,
87
kube::ResourceExt,
98
role_utils::{GenericRoleConfig, RoleGroup},
109
v2::role_utils::{GenericCommonConfig, with_validated_config},
@@ -13,11 +12,13 @@ use strum::IntoEnumIterator;
1312

1413
use super::dereference::DereferencedObjects;
1514
use crate::{
16-
airflow_controller::CONTAINER_IMAGE_BASE_NAME,
15+
airflow_controller::{
16+
CONTAINER_IMAGE_BASE_NAME, ValidatedAirflowCluster, ValidatedRoleConfig,
17+
ValidatedRoleGroupConfig,
18+
},
1719
crd::{
18-
AirflowConfig, AirflowConfigFragment, AirflowConfigOverrides, AirflowExecutor, AirflowRole,
19-
AirflowRoleType, authentication::AirflowClientAuthenticationDetailsResolved,
20-
authorization::AirflowAuthorizationResolved, v1alpha2,
20+
AirflowConfig, AirflowConfigFragment, AirflowConfigOverrides, AirflowRole, AirflowRoleType,
21+
v1alpha2,
2122
},
2223
};
2324

@@ -35,41 +36,6 @@ pub enum Error {
3536
},
3637
}
3738

38-
/// Per-role configuration extracted during validation.
39-
#[derive(Clone, Debug)]
40-
pub struct ValidatedRoleConfig {
41-
pub pdb: Option<stackable_operator::commons::pdb::PdbConfig>,
42-
pub listener_class: Option<String>,
43-
pub group_listener_name: Option<String>,
44-
}
45-
46-
/// Per-rolegroup configuration: the merged CRD config plus overrides.
47-
///
48-
/// `config_overrides` is kept as the typed [`AirflowConfigOverrides`] (role-group merged over
49-
/// role); it is flattened into the rendered config file later, in the build step. This mirrors
50-
/// hdfs-operator. `env_overrides` is already a flat map.
51-
#[derive(Clone, Debug)]
52-
pub struct ValidatedRoleGroupConfig {
53-
pub merged_config: AirflowConfig,
54-
pub config_overrides: AirflowConfigOverrides,
55-
pub env_overrides: HashMap<String, String>,
56-
pub replicas: Option<u16>,
57-
pub pod_overrides: PodTemplateSpec,
58-
}
59-
60-
/// The validated cluster: proves that config merging succeeded for every role and
61-
/// role group before any resources are created. It also carries the dereferenced
62-
/// external references, so every downstream build step reads them from here.
63-
#[derive(Clone, Debug)]
64-
pub struct ValidatedAirflowCluster {
65-
pub image: ResolvedProductImage,
66-
pub role_groups: BTreeMap<AirflowRole, BTreeMap<String, ValidatedRoleGroupConfig>>,
67-
pub role_configs: BTreeMap<AirflowRole, ValidatedRoleConfig>,
68-
pub executor: AirflowExecutor,
69-
pub authentication_config: AirflowClientAuthenticationDetailsResolved,
70-
pub authorization_config: AirflowAuthorizationResolved,
71-
}
72-
7339
pub fn validate_cluster(
7440
airflow: &v1alpha2::AirflowCluster,
7541
image_repository: &str,

0 commit comments

Comments
 (0)