Skip to content

Commit 8d8e345

Browse files
committed
chore: add warning if broker and results backend configured without a celery executor.
1 parent 14b0ed5 commit 8d8e345

1 file changed

Lines changed: 28 additions & 15 deletions

File tree

rust/operator-binary/src/airflow_controller.rs

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -394,22 +394,35 @@ pub async fn reconcile_airflow(
394394
.metadata_database
395395
.sqlalchemy_connection_details_with_templating("METADATA", &templating_mechanism);
396396

397-
let celery_database_connection_details =
398-
if let (Some(celery_results_backend), Some(celery_broker)) = (
399-
&airflow.spec.cluster_config.celery_results_backend,
400-
&airflow.spec.cluster_config.celery_broker,
397+
let celery_database_connection_details = if let (
398+
Some(celery_results_backend),
399+
Some(celery_broker),
400+
) = (
401+
&airflow.spec.cluster_config.celery_results_backend,
402+
&airflow.spec.cluster_config.celery_broker,
403+
) {
404+
// The celery results backend and celery broker only work with configured celeryExecutors.
405+
// Emit a warning if celery executors were not configured properly.
406+
if !matches!(
407+
&airflow.spec.executor,
408+
AirflowExecutor::CeleryExecutors { .. }
401409
) {
402-
let celery_results_backend = celery_results_backend
403-
.celery_connection_details_with_templating(
404-
"CELERY_RESULT_BACKEND",
405-
&templating_mechanism,
406-
);
407-
let celery_broker = celery_broker
408-
.celery_connection_details_with_templating("CELERY_BROKER", &templating_mechanism);
409-
Some((celery_results_backend, celery_broker))
410-
} else {
411-
None
412-
};
410+
tracing::warn!(
411+
"No `spec.celeryExecutors` configured, but `spec.clusterConfig.celeryResultsBackend` and `spec.clusterConfig.celeryBroker` are provided. This only works in combination with a celery executor!"
412+
)
413+
}
414+
415+
let celery_results_backend = celery_results_backend
416+
.celery_connection_details_with_templating(
417+
"CELERY_RESULT_BACKEND",
418+
&templating_mechanism,
419+
);
420+
let celery_broker = celery_broker
421+
.celery_connection_details_with_templating("CELERY_BROKER", &templating_mechanism);
422+
Some((celery_results_backend, celery_broker))
423+
} else {
424+
None
425+
};
413426

414427
let mut roles = HashMap::new();
415428

0 commit comments

Comments
 (0)