Skip to content

Commit a66bc67

Browse files
committed
pass validated cluster instead of individual parameters
1 parent 58c9d03 commit a66bc67

2 files changed

Lines changed: 27 additions & 41 deletions

File tree

rust/operator-binary/src/airflow_controller.rs

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use stackable_operator::{
6767
use strum::{EnumDiscriminants, IntoStaticStr};
6868

6969
use crate::{
70-
controller::build::config_map,
70+
controller::{build::config_map, validate::ValidatedAirflowCluster},
7171
controller_commons::{self, CONFIG_VOLUME_NAME, LOG_CONFIG_VOLUME_NAME, LOG_VOLUME_NAME},
7272
crd::{
7373
self, APP_NAME, AirflowClusterStatus, AirflowConfig, AirflowExecutor,
@@ -344,7 +344,7 @@ pub async fn reconcile_airflow(
344344
None
345345
};
346346

347-
let validated = crate::controller::validate::validate_cluster(
347+
let validated_cluster = crate::controller::validate::validate_cluster(
348348
airflow,
349349
&ctx.operator_environment.image_repository,
350350
dereferenced,
@@ -418,26 +418,24 @@ pub async fn reconcile_airflow(
418418
// collection there will be a pod template created to be used for pod provisioning
419419
if let AirflowExecutor::KubernetesExecutors {
420420
common_configuration,
421-
} = &validated.executor
421+
} = &validated_cluster.executor
422422
{
423423
build_executor_template(
424424
airflow,
425425
common_configuration,
426426
&metadata_database_connection_details,
427-
&validated.image,
428-
&validated.authentication_config,
429-
&validated.authorization_config,
427+
&validated_cluster,
430428
&mut cluster_resources,
431429
client,
432430
&rbac_sa,
433431
)
434432
.await?;
435433
}
436434

437-
for (airflow_role, role_group_configs) in &validated.role_groups {
435+
for (airflow_role, role_group_configs) in &validated_cluster.role_groups {
438436
let role_name = airflow_role.to_string();
439437

440-
if let Some(role_config) = validated.role_configs.get(airflow_role) {
438+
if let Some(role_config) = validated_cluster.role_configs.get(airflow_role) {
441439
if let Some(pdb) = &role_config.pdb {
442440
add_pdbs(pdb, airflow, airflow_role, client, &mut cluster_resources)
443441
.await
@@ -451,7 +449,7 @@ pub async fn reconcile_airflow(
451449
build_recommended_labels(
452450
airflow,
453451
AIRFLOW_CONTROLLER_NAME,
454-
&validated.image.app_version_label_value,
452+
&validated_cluster.image.app_version_label_value,
455453
&role_name,
456454
"none",
457455
),
@@ -475,7 +473,7 @@ pub async fn reconcile_airflow(
475473

476474
let git_sync_resources = git_sync::v1alpha2::GitSyncResources::new(
477475
&airflow.spec.cluster_config.dags_git_sync,
478-
&validated.image,
476+
&validated_cluster.image,
479477
&validated_rg_config
480478
.overrides
481479
.env_overrides
@@ -498,7 +496,7 @@ pub async fn reconcile_airflow(
498496
let role_group_service_recommended_labels = build_recommended_labels(
499497
airflow,
500498
AIRFLOW_CONTROLLER_NAME,
501-
&validated.image.app_version_label_value,
499+
&validated_cluster.image.app_version_label_value,
502500
&rolegroup.role,
503501
&rolegroup.role_group,
504502
);
@@ -542,11 +540,9 @@ pub async fn reconcile_airflow(
542540

543541
let rg_configmap = config_map::build_rolegroup_config_map(
544542
airflow,
545-
&validated.image,
543+
&validated_cluster,
546544
&rolegroup,
547545
&validated_rg_config.overrides.config_file_overrides,
548-
&validated.authentication_config,
549-
&validated.authorization_config,
550546
&validated_rg_config.merged_config.logging,
551547
&Container::Airflow,
552548
)
@@ -560,17 +556,17 @@ pub async fn reconcile_airflow(
560556

561557
let rg_statefulset = build_server_rolegroup_statefulset(
562558
airflow,
563-
&validated.image,
559+
&validated_cluster.image,
564560
airflow_role,
565561
&rolegroup,
566562
&validated_rg_config.overrides.env_overrides,
567-
&validated.authentication_config,
568-
&validated.authorization_config,
563+
&validated_cluster.authentication_config,
564+
&validated_cluster.authorization_config,
569565
&metadata_database_connection_details,
570566
&celery_database_connection_details,
571567
&rbac_sa,
572568
&validated_rg_config.merged_config,
573-
&validated.executor,
569+
&validated_cluster.executor,
574570
&git_sync_resources,
575571
)?;
576572

@@ -610,9 +606,7 @@ async fn build_executor_template(
610606
airflow: &v1alpha2::AirflowCluster,
611607
common_config: &AirflowExecutorCommonConfiguration,
612608
metadata_database_connection_details: &SqlAlchemyDatabaseConnectionDetails,
613-
resolved_product_image: &ResolvedProductImage,
614-
authentication_config: &AirflowClientAuthenticationDetailsResolved,
615-
authorization_config: &AirflowAuthorizationResolved,
609+
validated_cluster: &ValidatedAirflowCluster,
616610
cluster_resources: &mut ClusterResources<'_>,
617611
client: &stackable_operator::client::Client,
618612
rbac_sa: &stackable_operator::k8s_openapi::api::core::v1::ServiceAccount,
@@ -628,11 +622,9 @@ async fn build_executor_template(
628622

629623
let rg_configmap = config_map::build_rolegroup_config_map(
630624
airflow,
631-
resolved_product_image,
625+
validated_cluster,
632626
&rolegroup,
633627
&BTreeMap::new(),
634-
authentication_config,
635-
authorization_config,
636628
&merged_executor_config.logging,
637629
&Container::Base,
638630
)
@@ -646,7 +638,7 @@ async fn build_executor_template(
646638

647639
let git_sync_resources = git_sync::v1alpha2::GitSyncResources::new(
648640
&airflow.spec.cluster_config.dags_git_sync,
649-
resolved_product_image,
641+
&validated_cluster.image,
650642
&common_config
651643
.env_overrides
652644
.iter()
@@ -666,8 +658,8 @@ async fn build_executor_template(
666658

667659
let worker_pod_template_config_map = build_executor_template_config_map(
668660
airflow,
669-
resolved_product_image,
670-
authentication_config,
661+
&validated_cluster.image,
662+
&validated_cluster.authentication_config,
671663
metadata_database_connection_details,
672664
&rbac_sa.name_unchecked(),
673665
&merged_executor_config,

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::collections::BTreeMap;
66
use snafu::{ResultExt, Snafu};
77
use stackable_operator::{
88
builder::{configmap::ConfigMapBuilder, meta::ObjectMetaBuilder},
9-
commons::product_image_selection::ResolvedProductImage,
109
k8s_openapi::api::core::v1::ConfigMap,
1110
product_logging::spec::Logging,
1211
role_utils::RoleGroupRef,
@@ -15,11 +14,8 @@ use stackable_operator::{
1514
use crate::{
1615
airflow_controller::AIRFLOW_CONTROLLER_NAME,
1716
config::webserver_config,
18-
crd::{
19-
AIRFLOW_CONFIG_FILENAME, Container,
20-
authentication::AirflowClientAuthenticationDetailsResolved,
21-
authorization::AirflowAuthorizationResolved, build_recommended_labels, v1alpha2,
22-
},
17+
controller::validate::ValidatedAirflowCluster,
18+
crd::{AIRFLOW_CONFIG_FILENAME, Container, build_recommended_labels, v1alpha2},
2319
product_logging::extend_config_map_with_log_config,
2420
};
2521

@@ -58,18 +54,16 @@ pub enum Error {
5854
#[allow(clippy::too_many_arguments)]
5955
pub fn build_rolegroup_config_map(
6056
airflow: &v1alpha2::AirflowCluster,
61-
resolved_product_image: &ResolvedProductImage,
57+
validated_cluster: &ValidatedAirflowCluster,
6258
rolegroup: &RoleGroupRef<v1alpha2::AirflowCluster>,
6359
config_file_overrides: &BTreeMap<String, String>,
64-
authentication_config: &AirflowClientAuthenticationDetailsResolved,
65-
authorization_config: &AirflowAuthorizationResolved,
6660
logging: &Logging<Container>,
6761
container: &Container,
6862
) -> Result<ConfigMap, Error> {
6963
let config_file = webserver_config::build(
70-
authentication_config,
71-
authorization_config,
72-
&resolved_product_image.product_version,
64+
&validated_cluster.authentication_config,
65+
&validated_cluster.authorization_config,
66+
&validated_cluster.image.product_version,
7367
config_file_overrides,
7468
)
7569
.with_context(|_| BuildWebserverConfigSnafu {
@@ -88,7 +82,7 @@ pub fn build_rolegroup_config_map(
8882
.with_recommended_labels(&build_recommended_labels(
8983
airflow,
9084
AIRFLOW_CONTROLLER_NAME,
91-
&resolved_product_image.app_version_label_value,
85+
&validated_cluster.image.app_version_label_value,
9286
&rolegroup.role,
9387
&rolegroup.role_group,
9488
))
@@ -103,7 +97,7 @@ pub fn build_rolegroup_config_map(
10397
container,
10498
&Container::Vector,
10599
&mut cm_builder,
106-
resolved_product_image,
100+
&validated_cluster.image,
107101
)
108102
.context(InvalidLoggingConfigSnafu {
109103
cm_name: rolegroup.object_name(),

0 commit comments

Comments
 (0)