Skip to content

Commit 604d6ca

Browse files
committed
use v2 cluster_resources_new
1 parent 68fe562 commit 604d6ca

3 files changed

Lines changed: 24 additions & 24 deletions

File tree

rust/operator-binary/src/airflow_controller.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use stackable_operator::{
1313
crd::git_sync,
1414
k8s_openapi::api::core::v1::EnvVar,
1515
kube::{
16-
Resource, ResourceExt,
16+
ResourceExt,
1717
core::{DeserializeGuard, error_boundary},
1818
runtime::controller::Action,
1919
},
@@ -24,7 +24,10 @@ use stackable_operator::{
2424
compute_conditions, operations::ClusterOperationsConditionBuilder,
2525
statefulset::StatefulSetConditionBuilder,
2626
},
27-
v2::types::operator::{RoleGroupName, RoleName},
27+
v2::{
28+
cluster_resources::cluster_resources_new,
29+
types::operator::{RoleGroupName, RoleName},
30+
},
2831
};
2932
use strum::{EnumDiscriminants, IntoStaticStr};
3033

@@ -42,6 +45,7 @@ use crate::{
4245
},
4346
volumes::LOG_VOLUME_NAME,
4447
},
48+
controller_name, operator_name, product_name,
4549
},
4650
crd::{
4751
APP_NAME, AirflowClusterStatus, AirflowConfigOverrides, Container, OPERATOR_NAME,
@@ -134,11 +138,6 @@ pub enum Error {
134138
#[snafu(display("invalid git-sync specification"))]
135139
InvalidGitSyncSpec { source: git_sync::v1alpha2::Error },
136140

137-
#[snafu(display("failed to create cluster resources"))]
138-
CreateClusterResources {
139-
source: stackable_operator::cluster_resources::Error,
140-
},
141-
142141
#[snafu(display("failed to delete orphaned resources"))]
143142
DeleteOrphanedResources {
144143
source: stackable_operator::cluster_resources::Error,
@@ -239,7 +238,7 @@ pub async fn reconcile_airflow(
239238
validated_cluster.internal_secret_name().as_ref(),
240239
INTERNAL_SECRET_SECRET_KEY,
241240
256,
242-
airflow,
241+
&validated_cluster,
243242
client,
244243
)
245244
.await
@@ -249,7 +248,7 @@ pub async fn reconcile_airflow(
249248
validated_cluster.jwt_secret_name().as_ref(),
250249
JWT_SECRET_SECRET_KEY,
251250
256,
252-
airflow,
251+
&validated_cluster,
253252
client,
254253
)
255254
.await
@@ -263,21 +262,22 @@ pub async fn reconcile_airflow(
263262
validated_cluster.fernet_key_name().as_ref(),
264263
FERNET_KEY_SECRET_KEY,
265264
32,
266-
airflow,
265+
&validated_cluster,
267266
client,
268267
)
269268
.await
270269
.context(InternalSecretSnafu)?;
271270

272-
let mut cluster_resources = ClusterResources::new(
273-
APP_NAME,
274-
OPERATOR_NAME,
275-
AIRFLOW_CONTROLLER_NAME,
276-
&airflow.object_ref(&()),
271+
let mut cluster_resources = cluster_resources_new(
272+
&product_name(),
273+
&operator_name(),
274+
&controller_name(),
275+
&validated_cluster.name,
276+
&validated_cluster.namespace,
277+
&validated_cluster.uid,
277278
ClusterResourceApplyStrategy::from(&airflow.spec.cluster_operation),
278279
&airflow.spec.object_overrides,
279-
)
280-
.context(CreateClusterResourcesSnafu)?;
280+
);
281281

282282
let required_labels = cluster_resources
283283
.get_required_labels()

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,17 @@ impl ValidatedCluster {
400400
}
401401

402402
/// The product name (`airflow`) as a type-safe label value.
403-
fn product_name() -> ProductName {
403+
pub(crate) fn product_name() -> ProductName {
404404
ProductName::from_str(APP_NAME).expect("'airflow' is a valid product name")
405405
}
406406

407407
/// The operator name as a type-safe label value.
408-
fn operator_name() -> OperatorName {
408+
pub(crate) fn operator_name() -> OperatorName {
409409
OperatorName::from_str(OPERATOR_NAME).expect("the operator name is a valid label value")
410410
}
411411

412412
/// The controller name as a type-safe label value.
413-
fn controller_name() -> ControllerName {
413+
pub(crate) fn controller_name() -> ControllerName {
414414
ControllerName::from_str(AIRFLOW_CONTROLLER_NAME)
415415
.expect("the controller name is a valid label value")
416416
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,18 @@ pub fn validate_cluster(
169169
} = dereferenced;
170170

171171
// The Celery result-backend and broker only work with configured celeryExecutors. Emit a
172-
// warning if they are provided without a Celery executor. The connection details themselves are
172+
// warning if either are provided without a Celery executor. The connection details themselves are
173173
// derived from the CRD later, in the build step (see
174174
// `ValidatedCluster::celery_database_connection_details`).
175-
if airflow.spec.cluster_config.celery_results_backend.is_some()
176-
&& airflow.spec.cluster_config.celery_broker.is_some()
175+
if (airflow.spec.cluster_config.celery_results_backend.is_some()
176+
|| airflow.spec.cluster_config.celery_broker.is_some())
177177
&& !matches!(
178178
&airflow.spec.executor,
179179
AirflowExecutor::CeleryExecutors { .. }
180180
)
181181
{
182182
tracing::warn!(
183-
"No `spec.celeryExecutors` configured, but `spec.clusterConfig.celeryResultsBackend` and `spec.clusterConfig.celeryBroker` are provided. This only works in combination with a celery executor!"
183+
"No `spec.celeryExecutors` configured, but `spec.clusterConfig.celeryResultsBackend` and/or `spec.clusterConfig.celeryBroker` are provided. This only works in combination with a celery executor!"
184184
)
185185
}
186186

0 commit comments

Comments
 (0)