Skip to content

Commit 02b9f97

Browse files
chore: Version CRD and AirflowClusterConfig (#581)
* chore: Remove separate CRD crate * chore: Version AirflowCluster * chore: Reorder impl blocks * chore: Version AirflowClusterConfig * docs: Fix invalid rustdoc reference * chore: Apply suggestion Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> --------- Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
1 parent 0ca64d3 commit 02b9f97

18 files changed

+1904
-755
lines changed

Cargo.lock

Lines changed: 273 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 1140 additions & 211 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["rust/crd", "rust/operator-binary"]
2+
members = ["rust/operator-binary"]
33
resolver = "2"
44

55
[workspace.package]
@@ -10,21 +10,23 @@ edition = "2021"
1010
repository = "https://github.com/stackabletech/airflow-operator"
1111

1212
[workspace.dependencies]
13+
stackable-versioned = { git = "https://github.com/stackabletech/operator-rs.git", features = ["k8s"], tag = "stackable-versioned-0.5.0" }
14+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.85.0" }
15+
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
16+
1317
anyhow = "1.0"
1418
built = { version = "0.7", features = ["chrono", "git2"] }
1519
clap = "4.5"
1620
const_format = "0.2"
1721
fnv = "1.0"
1822
futures = { version = "0.3", features = ["compat"] }
1923
indoc = "2.0"
20-
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
2124
rstest = "0.24"
2225
semver = "1.0"
2326
serde = { version = "1.0", features = ["derive"] }
2427
serde_json = "1.0"
2528
serde_yaml = "0.9"
2629
snafu = "0.8"
27-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.85.0" }
2830
strum = { version = "0.26", features = ["derive"] }
2931
tokio = { version = "1.40", features = ["full"] }
3032
tracing = "0.1"

crate-hashes.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/crd/Cargo.toml

Lines changed: 0 additions & 24 deletions
This file was deleted.

rust/operator-binary/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ repository.workspace = true
99
publish = false
1010

1111
[dependencies]
12-
stackable-airflow-crd = { path = "../crd" }
12+
stackable-versioned.workspace = true
13+
stackable-operator.workspace = true
14+
product-config.workspace = true
1315

1416
anyhow.workspace = true
1517
clap.workspace = true
1618
const_format.workspace = true
1719
fnv.workspace = true
1820
futures.workspace = true
1921
serde.workspace = true
22+
serde_json.workspace = true
2023
serde_yaml.workspace = true
2124
snafu.workspace = true
22-
stackable-operator.workspace = true
23-
product-config.workspace = true
2425
strum.workspace = true
2526
tokio.workspace = true
2627
tracing.workspace = true

rust/operator-binary/src/airflow_controller.rs

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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`]
22
use std::{
33
collections::{BTreeMap, BTreeSet, HashMap},
44
io::Write,
@@ -13,18 +13,6 @@ use product_config::{
1313
ProductConfigManager,
1414
};
1515
use 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-
};
2816
use stackable_operator::{
2917
builder::{
3018
self,
@@ -86,6 +74,18 @@ use strum::{EnumDiscriminants, IntoEnumIterator, IntoStaticStr};
8674
use 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)]
117116
pub 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

338333
pub 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)]
560555
async 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.
614609
fn 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)]
676671
fn 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.
762757
fn 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

809804
fn 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)]
837832
fn 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)]
11181113
fn 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

12941289
pub fn error_policy(
1295-
_obj: Arc<DeserializeGuard<AirflowCluster>>,
1290+
_obj: Arc<DeserializeGuard<v1alpha1::AirflowCluster>>,
12961291
error: &Error,
12971292
_ctx: Arc<Ctx>,
12981293
) -> Action {

rust/operator-binary/src/config.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ use std::collections::BTreeMap;
22

33
use indoc::formatdoc;
44
use snafu::{ResultExt, Snafu};
5-
use stackable_airflow_crd::{
5+
use stackable_operator::commons::{
6+
authentication::{ldap::AuthenticationProvider, oidc},
7+
tls_verification::TlsVerification,
8+
};
9+
10+
use crate::crd::{
611
authentication::{
712
AirflowAuthenticationClassResolved, AirflowClientAuthenticationDetailsResolved,
813
FlaskRolesSyncMoment, DEFAULT_OIDC_PROVIDER,
914
},
1015
AirflowConfigOptions,
1116
};
12-
use stackable_operator::commons::{
13-
authentication::{ldap::AuthenticationProvider, oidc},
14-
tls_verification::TlsVerification,
15-
};
1617

1718
pub const PYTHON_IMPORTS: &[&str] = &[
1819
"import os",
@@ -280,13 +281,15 @@ mod tests {
280281

281282
use indoc::formatdoc;
282283
use rstest::rstest;
283-
use stackable_airflow_crd::authentication::{
284-
default_sync_roles_at, default_user_registration, AirflowAuthenticationClassResolved,
285-
AirflowClientAuthenticationDetailsResolved, FlaskRolesSyncMoment,
286-
};
287284
use stackable_operator::commons::authentication::{ldap, oidc};
288285

289-
use crate::config::add_airflow_config;
286+
use crate::{
287+
config::add_airflow_config,
288+
crd::authentication::{
289+
default_user_registration, AirflowAuthenticationClassResolved,
290+
AirflowClientAuthenticationDetailsResolved, FlaskRolesSyncMoment,
291+
},
292+
};
290293

291294
#[test]
292295
fn test_auth_db_config() {
@@ -421,7 +424,7 @@ mod tests {
421424
],
422425
user_registration: default_user_registration(),
423426
user_registration_role: "Admin".to_string(),
424-
sync_roles_at: default_sync_roles_at(),
427+
sync_roles_at: FlaskRolesSyncMoment::Registration,
425428
};
426429

427430
let mut result = BTreeMap::new();

rust/operator-binary/src/controller_commons.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use stackable_airflow_crd::MAX_LOG_FILES_SIZE;
21
use stackable_operator::{
32
builder::pod::volume::VolumeBuilder,
43
k8s_openapi::api::core::v1::{ConfigMapVolumeSource, EmptyDirVolumeSource, Volume},
@@ -11,6 +10,8 @@ use stackable_operator::{
1110
},
1211
};
1312

13+
use crate::crd::MAX_LOG_FILES_SIZE;
14+
1415
pub const CONFIG_VOLUME_NAME: &str = "config";
1516
pub const LOG_CONFIG_VOLUME_NAME: &str = "log-config";
1617
pub const LOG_VOLUME_NAME: &str = "log";

0 commit comments

Comments
 (0)