From 05cc72fef7dba2c4bf19cf59116ce2f16cfb7b53 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Tue, 24 Nov 2026 10:38:51 +0100 Subject: [PATCH 1/9] chore!: Remove the Airflow 2.x specific code paths --- CHANGELOG.md | 6 + .../src/controller/build/mod.rs | 68 ------ .../controller/build/properties/env_vars.rs | 226 ++++++------------ .../build/properties/product_logging/mod.rs | 32 +-- .../build/properties/webserver_config.rs | 115 +-------- rust/operator-binary/src/crd/mod.rs | 168 ++++--------- .../src/crd/trusted_proxies.rs | 6 - 7 files changed, 148 insertions(+), 473 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b8918d7..a4959db1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] +### Removed + +- BREAKING: Remove the Airflow 2.x specific code paths ([#901]). + +[#901]: https://github.com/stackabletech/airflow-operator/pull/901 + ## [26.11.0] - 2026-11-20 ## [26.11.0-rc1] - 2026-11-19 diff --git a/rust/operator-binary/src/controller/build/mod.rs b/rust/operator-binary/src/controller/build/mod.rs index 8ef128cc..ea96ab24 100644 --- a/rust/operator-binary/src/controller/build/mod.rs +++ b/rust/operator-binary/src/controller/build/mod.rs @@ -553,7 +553,6 @@ mod tests { #[rstest] #[case::airflow_3x("3.3.2")] - #[case::airflow_2x("2.9.3")] fn admin_password_is_not_traced(#[case] product_version: &str) { let cluster = validated_cluster_with( "celeryExecutors", @@ -717,73 +716,6 @@ mod tests { assert_eq!(env.get("FORWARDED_ALLOW_IPS"), None); } - /// Builds a 2.x Celery-executor cluster whose webserver trusts the given reverse proxies. - fn cluster_with_trusted_proxies_on_airflow_2x(trusted_proxies: &[&str]) -> ValidatedCluster { - let trusted_proxies: Vec = trusted_proxies - .iter() - .map(|proxy| yaml_serde::Value::String((*proxy).to_owned())) - .collect(); - - validated_cluster_with( - "celeryExecutors", - "{config: {}, roleGroups: {}}", - move |cluster| { - cluster["spec"]["image"]["productVersion"] = yaml_serde::Value::from("2.9.3"); - cluster["spec"]["webservers"] - .as_mapping_mut() - .expect("the webservers role is a mapping") - .insert( - "roleConfig".into(), - yaml_serde::Value::Mapping(yaml_serde::Mapping::from_iter([( - yaml_serde::Value::String("trustedProxies".to_owned()), - yaml_serde::Value::Sequence(trusted_proxies.clone()), - )])), - ); - }, - ) - } - - #[test] - fn trusted_proxies_enables_proxy_fix_on_airflow_2x() { - let cluster = cluster_with_trusted_proxies_on_airflow_2x(&["10.244.0.0/16"]); - - let args = airflow_container_args(&cluster, "my-airflow-webserver-default"); - assert!(args.contains("airflow webserver &"), "args were:\n{args}"); - assert!(!args.contains("--proxy-headers"), "args were:\n{args}"); - - let env = airflow_container_env(&cluster, "my-airflow-webserver-default"); - assert_eq!(env.get("FORWARDED_ALLOW_IPS"), None); - assert_eq!( - env.get("AIRFLOW__WEBSERVER__ENABLE_PROXY_FIX"), - Some(&"True".to_owned()) - ); - assert_eq!( - env.get("AIRFLOW__WEBSERVER__PROXY_FIX_X_FOR"), - Some(&"1".to_owned()) - ); - } - - #[test] - fn wildcard_trusted_proxies_enables_proxy_fix_on_airflow_2x() { - let cluster = cluster_with_trusted_proxies_on_airflow_2x(&["*"]); - - let env = airflow_container_env(&cluster, "my-airflow-webserver-default"); - assert_eq!( - env.get("AIRFLOW__WEBSERVER__ENABLE_PROXY_FIX"), - Some(&"True".to_owned()) - ); - } - - /// No `trustedProxies` means no `ProxyFix` on Airflow 2.x either. - #[test] - fn no_proxy_fix_without_trusted_proxies_on_airflow_2x() { - let cluster = cluster_with_trusted_proxies_on_airflow_2x(&[]); - - let env = airflow_container_env(&cluster, "my-airflow-webserver-default"); - assert_eq!(env.get("AIRFLOW__WEBSERVER__ENABLE_PROXY_FIX"), None); - assert_eq!(env.get("AIRFLOW__WEBSERVER__PROXY_FIX_X_FOR"), None); - } - /// A cluster with the given `spec.clusterConfig.volumeMounts` (as standalone YAML). fn cluster_with_user_volume_mounts( executor_key: &str, diff --git a/rust/operator-binary/src/controller/build/properties/env_vars.rs b/rust/operator-binary/src/controller/build/properties/env_vars.rs index 7bd0549c..7daa445a 100644 --- a/rust/operator-binary/src/controller/build/properties/env_vars.rs +++ b/rust/operator-binary/src/controller/build/properties/env_vars.rs @@ -47,9 +47,6 @@ constant!(AIRFLOW_CELERY_BROKER_URL: EnvVarName = "AIRFLOW__CELERY__BROKER_URL") constant!(AIRFLOW_CORE_DAGS_FOLDER: EnvVarName = "AIRFLOW__CORE__DAGS_FOLDER"); constant!(AIRFLOW_CORE_LOAD_EXAMPLES: EnvVarName = "AIRFLOW__CORE__LOAD_EXAMPLES"); constant!(AIRFLOW_API_AUTH_BACKENDS: EnvVarName = "AIRFLOW__API__AUTH_BACKENDS"); -constant!(AIRFLOW_WEBSERVER_ENABLE_PROXY_FIX: EnvVarName = "AIRFLOW__WEBSERVER__ENABLE_PROXY_FIX"); -constant!(AIRFLOW_WEBSERVER_PROXY_FIX_X_FOR: EnvVarName = "AIRFLOW__WEBSERVER__PROXY_FIX_X_FOR"); -constant!(AIRFLOW_SCHEDULER_STANDALONE_DAG_PROCESSOR: EnvVarName = "AIRFLOW__SCHEDULER__STANDALONE_DAG_PROCESSOR"); constant!(AIRFLOW_API_AUTH_JWT_SECRET: EnvVarName = "AIRFLOW__API_AUTH__JWT_SECRET"); constant!(AIRFLOW_API_WORKERS: EnvVarName = "AIRFLOW__API__WORKERS"); constant!(AIRFLOW_FAB_UPDATE_FAB_PERMS: EnvVarName = "AIRFLOW__FAB__UPDATE_FAB_PERMS"); @@ -93,14 +90,13 @@ pub fn build_airflow_statefulset_envs( let executor = &cluster.cluster_config.executor; let auth_config = &cluster.cluster_config.authentication_config; let authorization_config = &cluster.cluster_config.authorization_config; - let resolved_product_image = &cluster.image; let metadata_database_connection_details = cluster.metadata_database_connection_details(); let celery_database_connection_details = cluster.celery_database_connection_details(); let internal_secret_name = cluster.internal_secret_name(); let mut env_vars = static_envs(git_sync_resources) - .merge(add_version_specific_env_vars(cluster, airflow_role)) + .merge(add_core_env_vars(cluster, airflow_role)) // Replaces AIRFLOW__WEBSERVER__SECRET_KEY >= 3.0.2. .with_secret_key_ref( &AIRFLOW_API_SECRET_KEY, @@ -167,13 +163,9 @@ pub fn build_airflow_statefulset_envs( .with_secret_key_ref(&ADMIN_PASSWORD, secret, &ADMIN_PASSWORD_SECRET_KEY); } AirflowRole::Webserver => { - env_vars = - env_vars - .merge(authentication_env_vars(auth_config)) - .merge(authorization_env_vars( - authorization_config, - &resolved_product_image.product_version, - )); + env_vars = env_vars + .merge(authentication_env_vars(auth_config)) + .merge(authorization_env_vars(authorization_config)); } _ => {} } @@ -263,7 +255,7 @@ pub fn build_airflow_template_envs( .with_value(&AIRFLOW_KUBERNETES_EXECUTOR_NAMESPACE, &cluster.namespace) .with_value(&AIRFLOW_CORE_DAGS_FOLDER, dags_folder) .merge(static_envs(git_sync_resources)) - .merge(add_version_specific_env_vars(cluster, &AirflowRole::Worker)); + .merge(add_core_env_vars(cluster, &AirflowRole::Worker)); // _STACKABLE_POST_HOOK will contain a command to create a shutdown hook that will be // evaluated in the wrapper for each stackable spark container: this is necessary for pods @@ -306,94 +298,56 @@ fn lineage_env_vars(cluster: &ValidatedCluster) -> EnvVarSet { }) } -fn add_version_specific_env_vars( - cluster: &ValidatedCluster, - airflow_role: &AirflowRole, -) -> EnvVarSet { - let mut env_vars = EnvVarSet::new(); - - if cluster.image.product_version.starts_with("3.") { - env_vars = env_vars - .merge(execution_server_env_vars(cluster)) - .with_value( - &AIRFLOW_CORE_AUTH_MANAGER, - "airflow.providers.fab.auth_manager.fab_auth_manager.FabAuthManager", - ) - .with_value( - &AIRFLOW_API_AUTH_BACKENDS, - "airflow.api.auth.backend.session", - ) - // As of 3.x a JWT key is required. - // See https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#jwt-secret - // This should be random, but must also be consistent across - // api-services and replicas/roles for a given - // cluster, but should also be cluster-specific. - // It is accessed from a secret to avoid cluster restarts - // being triggered by an operator restart. - .with_secret_key_ref( - &AIRFLOW_API_AUTH_JWT_SECRET, - &cluster.jwt_secret_name(), - &JWT_SECRET_SECRET_KEY, - ) - // The Airflow default for this is 4. - // However, with the default resources this could cause problems, - // as the Pod went to 100% CPU usage and didn't get healthy - // quick enough, resulting in a crashloop. - .with_value(&AIRFLOW_API_WORKERS, "1"); - if airflow_role == &AirflowRole::Webserver { - // Sometimes a race condition can arise when both scheduler and - // api-server are updating the DB, which adds overhead (conflicts - // are logged) and can result in inconsistencies. This setting - // ensure that only the scheduler will do this by default. - env_vars = env_vars.with_value(&AIRFLOW_FAB_UPDATE_FAB_PERMS, "False"); - - // This env var is needed in addition to `--proxy-headers` when Airflow runs - // behind a reverse proxy. - // This covers the uvicorn backend, the only one the SDP image can run. - let trusted_proxies = cluster - .trusted_proxies(airflow_role) - .iter() - .map(TrustedProxy::to_string) - .collect::>() - .join(","); - - if !trusted_proxies.is_empty() { - env_vars = env_vars.with_value(&FORWARDED_ALLOW_IPS, trusted_proxies); - } - } - } else { - env_vars = env_vars.with_value( +/// Constructs the env vars that every Airflow role needs, independent of its role-specific +/// configuration. +fn add_core_env_vars(cluster: &ValidatedCluster, airflow_role: &AirflowRole) -> EnvVarSet { + let mut env_vars = EnvVarSet::new() + .merge(execution_server_env_vars(cluster)) + .with_value( + &AIRFLOW_CORE_AUTH_MANAGER, + "airflow.providers.fab.auth_manager.fab_auth_manager.FabAuthManager", + ) + .with_value( &AIRFLOW_API_AUTH_BACKENDS, - "airflow.api.auth.backend.basic_auth, airflow.api.auth.backend.session", - ); - - // The 2.x uses Werkzeug's `ProxyFix` to allow forwarded-headers and it does so regardless - // of the peer source. The only valid value for `spec.webservers.roleConfig.trustedProxies` is `["*"]`. - if airflow_role == &AirflowRole::Webserver { - let trusted_proxies = cluster.trusted_proxies(airflow_role); - - if !trusted_proxies.is_empty() { - env_vars = env_vars - .with_value(&AIRFLOW_WEBSERVER_ENABLE_PROXY_FIX, "True") - .with_value(&AIRFLOW_WEBSERVER_PROXY_FIX_X_FOR, "1"); - - if !trusted_proxies.iter().any(TrustedProxy::is_wildcard) { - let product_version = &cluster.image.product_version; - tracing::warn!( - "spec.webservers.roleConfig.trustedProxies lists specific addresses, but \ - Airflow {product_version}'s webserver has no way to restrict forwarded \ - headers to specific peers -- once enabled it trusts X-Forwarded-* from \ - any peer, the same as \"*\"", - ); - } - } - } - - if cluster.has_role(&AirflowRole::DagProcessor) { - // In airflow 2.x the dag-processor can optionally be started as a - // standalone process (rather then as a scheduler subprocess), - // accompanied by this env-var being set to True. - env_vars = env_vars.with_value(&AIRFLOW_SCHEDULER_STANDALONE_DAG_PROCESSOR, "True"); + "airflow.api.auth.backend.session", + ) + // A JWT key is required. + // See https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#jwt-secret + // This should be random, but must also be consistent across + // api-services and replicas/roles for a given + // cluster, but should also be cluster-specific. + // It is accessed from a secret to avoid cluster restarts + // being triggered by an operator restart. + .with_secret_key_ref( + &AIRFLOW_API_AUTH_JWT_SECRET, + &cluster.jwt_secret_name(), + &JWT_SECRET_SECRET_KEY, + ) + // The Airflow default for this is 4. + // However, with the default resources this could cause problems, + // as the Pod went to 100% CPU usage and didn't get healthy + // quick enough, resulting in a crashloop. + .with_value(&AIRFLOW_API_WORKERS, "1"); + + if airflow_role == &AirflowRole::Webserver { + // Sometimes a race condition can arise when both scheduler and + // api-server are updating the DB, which adds overhead (conflicts + // are logged) and can result in inconsistencies. This setting + // ensure that only the scheduler will do this by default. + env_vars = env_vars.with_value(&AIRFLOW_FAB_UPDATE_FAB_PERMS, "False"); + + // This env var is needed in addition to `--proxy-headers` when Airflow runs + // behind a reverse proxy. + // This covers the uvicorn backend, the only one the SDP image can run. + let trusted_proxies = cluster + .trusted_proxies(airflow_role) + .iter() + .map(TrustedProxy::to_string) + .collect::>() + .join(","); + + if !trusted_proxies.is_empty() { + env_vars = env_vars.with_value(&FORWARDED_ALLOW_IPS, trusted_proxies); } } @@ -428,40 +382,29 @@ fn authentication_env_vars(auth_config: &AirflowClientAuthenticationDetailsResol ) } -/// Constructs the needed authorization env vars for the specific Airflow version. -/// -/// `AIRFLOW__CORE__AUTH_MANAGER` always needs to be set as env var. +/// Constructs the needed authorization env vars. /// -/// Airflow 2 needs to OPA settings in the `webserver_config.py` such as `AUTH_OPA_REQUEST_URL`. -/// Airflow 3 needs to OPA settings as env variables such as `AIRFLOW__CORE__AUTH_OPA_REQUEST_URL`. -fn authorization_env_vars( - authorization_config: &AirflowAuthorizationResolved, - product_version: &str, -) -> EnvVarSet { +/// `AIRFLOW__CORE__AUTH_MANAGER` always needs to be set as env var, and the OPA settings are +/// passed as env variables such as `AIRFLOW__CORE__AUTH_OPA_REQUEST_URL`. +fn authorization_env_vars(authorization_config: &AirflowAuthorizationResolved) -> EnvVarSet { let Some(opa) = &authorization_config.opa else { return EnvVarSet::new(); }; - let mut env_vars = EnvVarSet::new().with_value( - &AIRFLOW_CORE_AUTH_MANAGER, - "opa_auth_manager.opa_fab_auth_manager.OpaFabAuthManager", - ); - if product_version.starts_with("2.") { - // OPA config needs to go into `webserver_config.py` - } else { - env_vars = env_vars - .with_value(&AIRFLOW_CORE_AUTH_OPA_REQUEST_URL, &opa.connection_string) - .with_value( - &AIRFLOW_CORE_AUTH_OPA_CACHE_TTL_IN_SEC, - opa.cache_entry_time_to_live.as_secs().to_string(), - ) - .with_value( - &AIRFLOW_CORE_AUTH_OPA_CACHE_MAXSIZE, - opa.cache_max_entries.to_string(), - ); - } - - env_vars + EnvVarSet::new() + .with_value( + &AIRFLOW_CORE_AUTH_MANAGER, + "opa_auth_manager.opa_fab_auth_manager.OpaFabAuthManager", + ) + .with_value(&AIRFLOW_CORE_AUTH_OPA_REQUEST_URL, &opa.connection_string) + .with_value( + &AIRFLOW_CORE_AUTH_OPA_CACHE_TTL_IN_SEC, + opa.cache_entry_time_to_live.as_secs().to_string(), + ) + .with_value( + &AIRFLOW_CORE_AUTH_OPA_CACHE_MAXSIZE, + opa.cache_max_entries.to_string(), + ) } fn execution_server_env_vars(cluster: &ValidatedCluster) -> EnvVarSet { @@ -533,37 +476,16 @@ mod tests { let _ = *AIRFLOW_METRICS_STATSD_HOST; let _ = *AIRFLOW_METRICS_STATSD_ON; let _ = *AIRFLOW_METRICS_STATSD_PORT; - let _ = *AIRFLOW_SCHEDULER_STANDALONE_DAG_PROCESSOR; - let _ = *AIRFLOW_WEBSERVER_ENABLE_PROXY_FIX; let _ = *AIRFLOW_WEBSERVER_EXPOSE_CONFIG; - let _ = *AIRFLOW_WEBSERVER_PROXY_FIX_X_FOR; let _ = *FORWARDED_ALLOW_IPS; let _ = *PYTHONPATH; let _ = *STACKABLE_POST_HOOK; } #[test] - fn test_airflow_2_authorization_env_vars() { - let authorization_config = get_test_authorization_config(); - let authorization_env_vars = authorization_env_vars(&authorization_config, "2.10.5"); - let authorization_env_vars = authorization_env_vars - .into_iter() - .map(|env| (env.name, env.value.expect("env var value must be present"))) - .collect::>(); - - assert_eq!( - authorization_env_vars, - [( - "AIRFLOW__CORE__AUTH_MANAGER".into(), - "opa_auth_manager.opa_fab_auth_manager.OpaFabAuthManager".into() - ),] - ); - } - - #[test] - fn test_airflow_3_authorization_env_vars() { + fn authorization_env_vars_with_opa() { let authorization_config = get_test_authorization_config(); - let authorization_env_vars = authorization_env_vars(&authorization_config, "3.3.2"); + let authorization_env_vars = authorization_env_vars(&authorization_config); let authorization_env_vars = authorization_env_vars .into_iter() .map(|env| (env.name, env.value.expect("env var value must be present"))) diff --git a/rust/operator-binary/src/controller/build/properties/product_logging/mod.rs b/rust/operator-binary/src/controller/build/properties/product_logging/mod.rs index bbf1840a..f34c409d 100644 --- a/rust/operator-binary/src/controller/build/properties/product_logging/mod.rs +++ b/rust/operator-binary/src/controller/build/properties/product_logging/mod.rs @@ -41,10 +41,8 @@ pub fn create_airflow_config( return None; }; - let config = if resolved_product_image.product_version.starts_with("2.") - || resolved_product_image.product_version.starts_with("3.0.") - { - create_airflow_stdlib_config(log_config, log_dir, resolved_product_image) + let config = if resolved_product_image.product_version.starts_with("3.0.") { + create_airflow_stdlib_config(log_config, log_dir) } else { create_airflow_structlog_config(log_config, log_dir) }; @@ -52,11 +50,7 @@ pub fn create_airflow_config( Some(config) } -fn create_airflow_stdlib_config( - log_config: &AutomaticContainerLogConfig, - log_dir: &str, - resolved_product_image: &ResolvedProductImage, -) -> String { +fn create_airflow_stdlib_config(log_config: &AutomaticContainerLogConfig, log_dir: &str) -> String { let loggers_config = log_config .loggers .iter() @@ -78,16 +72,12 @@ LOGGING_CONFIG['loggers']['{name}']['level'] = {level} output }); - let remote_task_log = if resolved_product_image.product_version.starts_with("2.") { - "" - } else { - " + let remote_task_log = " # This will cause the relevant RemoteLogIO handler to be initialized REMOTE_TASK_LOG = airflow_local_settings.REMOTE_TASK_LOG log = logging.getLogger(__name__) log.info('Custom logging remote task log %s', REMOTE_TASK_LOG) -" - }; +"; format!( "\ @@ -315,11 +305,7 @@ mod tests { let log_config = AutomaticContainerLogConfig::default(); for content in [ - create_airflow_stdlib_config( - &log_config, - "/stackable/log/airflow", - &resolved_image("3.3.2"), - ), + create_airflow_stdlib_config(&log_config, "/stackable/log/airflow"), create_airflow_structlog_config(&log_config, "/stackable/log/airflow"), ] { assert!(content.contains("os.makedirs('/stackable/log/airflow', exist_ok=True)")); @@ -333,8 +319,8 @@ mod tests { fn test_logging_variant_selection() { // The stdlib config copies Airflow's default logging config, the structlog one // defines its own `mask_secrets_core` filter. - // N.B. This test assumes either Airflow 2.* or 3.0.* for stdlib_content as the - // code branches at this point. + // N.B. This test assumes Airflow 3.0.* for stdlib_content as the code branches at + // this point. let log_config = ValidatedContainerLogConfigChoice::Automatic(AutomaticContainerLogConfig::default()); let stdlib_content = create_airflow_config( @@ -402,7 +388,7 @@ mod tests { } fn stdlib_config(log_config: &AutomaticContainerLogConfig) -> String { - create_airflow_stdlib_config(log_config, "/stackable/log", &resolved_image("2.10.0")) + create_airflow_stdlib_config(log_config, "/stackable/log") } /// The requested level paired with the `task` handler level and the `airflow.task` logger diff --git a/rust/operator-binary/src/controller/build/properties/webserver_config.rs b/rust/operator-binary/src/controller/build/properties/webserver_config.rs index 16d38bc1..42f6e7c9 100644 --- a/rust/operator-binary/src/controller/build/properties/webserver_config.rs +++ b/rust/operator-binary/src/controller/build/properties/webserver_config.rs @@ -19,7 +19,6 @@ use crate::{ AirflowAuthenticationClassResolved, AirflowClientAuthenticationDetailsResolved, DEFAULT_OIDC_PROVIDER, FlaskRolesSyncMoment, }, - authorization::AirflowAuthorizationResolved, }, }; @@ -65,11 +64,7 @@ pub fn build( config_file_overrides: &BTreeMap, ) -> Result { // this will call default values from AirflowClientAuthenticationDetails - let mut config = build_airflow_config( - &validated_cluster.cluster_config.authentication_config, - &validated_cluster.cluster_config.authorization_config, - &validated_cluster.image.product_version, - )?; + let mut config = build_airflow_config(&validated_cluster.cluster_config.authentication_config)?; let mut file_config = config_file_overrides.clone(); @@ -119,13 +114,11 @@ pub fn build( } /// Builds the operator-default `webserver_config.py` entries derived from the resolved -/// authentication/authorization config. +/// authentication config. /// /// Returns the assembled map; the caller applies user `config_overrides` on top. pub fn build_airflow_config( authentication_config: &AirflowClientAuthenticationDetailsResolved, - authorization_config: &AirflowAuthorizationResolved, - product_version: &str, ) -> Result> { let mut config = BTreeMap::new(); @@ -133,7 +126,6 @@ pub fn build_airflow_config( config.insert(AirflowConfigOptions::AuthType.to_string(), "AUTH_DB".into()); append_authentication_config(&mut config, authentication_config)?; - append_authorization_config(&mut config, authorization_config, product_version); Ok(config) } @@ -361,35 +353,6 @@ fn append_oidc_config( Ok(()) } -fn append_authorization_config( - config: &mut BTreeMap, - authorization_config: &AirflowAuthorizationResolved, - product_version: &str, -) { - // See `env_vars::authorization_env_vars` for why we only care about Airflow 2 - if !product_version.starts_with("2.") { - return; - } - let Some(opa_config) = &authorization_config.opa else { - return; - }; - - config.extend([ - ( - AirflowConfigOptions::AuthOpaRequestUrl.to_string(), - opa_config.connection_string.to_owned(), - ), - ( - AirflowConfigOptions::AuthOpaCacheTtlInSec.to_string(), - opa_config.cache_entry_time_to_live.as_secs().to_string(), - ), - ( - AirflowConfigOptions::AuthOpaCacheMaxsize.to_string(), - opa_config.cache_max_entries.to_string(), - ), - ]); -} - #[cfg(test)] mod tests { use std::collections::BTreeMap; @@ -398,21 +361,15 @@ mod tests { use rstest::rstest; use stackable_operator::{ crd::authentication::{ldap, oidc}, - shared::time::Duration, utils::yaml_from_str_singleton_map, }; use super::build_airflow_config; - use crate::crd::{ - authentication::{ - AirflowAuthenticationClassResolved, AirflowClientAuthenticationDetailsResolved, - FlaskRolesSyncMoment, default_user_registration, - }, - authorization::{AirflowAuthorizationResolved, OpaConfigResolved}, + use crate::crd::authentication::{ + AirflowAuthenticationClassResolved, AirflowClientAuthenticationDetailsResolved, + FlaskRolesSyncMoment, default_user_registration, }; - const TEST_AIRFLOW_VERSION: &str = "3.3.2"; - #[test] fn test_auth_db_config() { let authentication_config = AirflowClientAuthenticationDetailsResolved { @@ -422,14 +379,7 @@ mod tests { sync_roles_at: FlaskRolesSyncMoment::Registration, }; - let authorization_config = AirflowAuthorizationResolved { opa: None }; - - let result = build_airflow_config( - &authentication_config, - &authorization_config, - TEST_AIRFLOW_VERSION, - ) - .expect("Ok"); + let result = build_airflow_config(&authentication_config).expect("Ok"); assert_eq!( BTreeMap::from([ @@ -470,14 +420,7 @@ mod tests { sync_roles_at: FlaskRolesSyncMoment::Registration, }; - let authorization_config = AirflowAuthorizationResolved { opa: None }; - - let result = build_airflow_config( - &authentication_config, - &authorization_config, - TEST_AIRFLOW_VERSION, - ) - .expect("Ok"); + let result = build_airflow_config(&authentication_config).expect("Ok"); assert_eq!(BTreeMap::from([ ("AUTH_LDAP_ALLOW_SELF_SIGNED".into(), "false".into()), @@ -562,14 +505,7 @@ mod tests { sync_roles_at: FlaskRolesSyncMoment::Registration, }; - let authorization_config = AirflowAuthorizationResolved { opa: None }; - - let result = build_airflow_config( - &authentication_config, - &authorization_config, - TEST_AIRFLOW_VERSION, - ) - .expect("Ok"); + let result = build_airflow_config(&authentication_config).expect("Ok"); assert_eq!( BTreeMap::from([ @@ -616,39 +552,4 @@ mod tests { result ); } - - #[test] - fn test_opa_config() { - let authentication_config = AirflowClientAuthenticationDetailsResolved { - authentication_classes_resolved: vec![], - user_registration: true, - user_registration_role: "User".to_string(), - sync_roles_at: FlaskRolesSyncMoment::Registration, - }; - - let authorization_config = AirflowAuthorizationResolved { - opa: Some(OpaConfigResolved { - connection_string: "http://opa:8081/v1/data/airflow".to_string(), - cache_entry_time_to_live: Duration::from_secs(30), - cache_max_entries: 1000, - }), - }; - - let result = build_airflow_config( - &authentication_config, - &authorization_config, - TEST_AIRFLOW_VERSION, - ) - .expect("Ok"); - - assert_eq!( - BTreeMap::from([ - ("AUTH_ROLES_SYNC_AT_LOGIN".into(), "false".into()), - ("AUTH_TYPE".into(), "AUTH_DB".into()), - ("AUTH_USER_REGISTRATION".into(), "true".into()), - ("AUTH_USER_REGISTRATION_ROLE".into(), "User".into()) - ]), - result - ); - } } diff --git a/rust/operator-binary/src/crd/mod.rs b/rust/operator-binary/src/crd/mod.rs index f4eedf94..d665d068 100644 --- a/rust/operator-binary/src/crd/mod.rs +++ b/rust/operator-binary/src/crd/mod.rs @@ -172,13 +172,6 @@ pub enum AirflowConfigOptions { AuthLdapTlsKeyfile, AuthLdapTlsCacertfile, AuthLdapAllowSelfSigned, - // OPA configs for Airflow 2 - // Airflow 3 configs need to be passed via env variables! - // See `env_vars::authorization_env_vars` for details - AuthOpaCacheMaxsize, - AuthOpaCacheTtlInSec, - AuthOpaRequestUrl, - AuthOpaRequestTimeout, } impl FlaskAppConfigOptions for AirflowConfigOptions { @@ -204,10 +197,6 @@ impl FlaskAppConfigOptions for AirflowConfigOptions { AirflowConfigOptions::AuthLdapTlsKeyfile => PythonType::StringLiteral, AirflowConfigOptions::AuthLdapTlsCacertfile => PythonType::StringLiteral, AirflowConfigOptions::AuthLdapAllowSelfSigned => PythonType::BoolLiteral, - AirflowConfigOptions::AuthOpaCacheMaxsize => PythonType::IntLiteral, - AirflowConfigOptions::AuthOpaCacheTtlInSec => PythonType::IntLiteral, - AirflowConfigOptions::AuthOpaRequestUrl => PythonType::StringLiteral, - AirflowConfigOptions::AuthOpaRequestTimeout => PythonType::IntLiteral, } } } @@ -575,7 +564,6 @@ impl AirflowRole { /// if authentication is enabled. pub fn get_commands(&self, cluster: &ValidatedCluster) -> Vec { let auth_config = &cluster.cluster_config.authentication_config; - let resolved_product_image = &cluster.image; let database_initialization_enabled = cluster.cluster_config.database_initialization_enabled; let has_dag_processors = cluster.has_role(&AirflowRole::DagProcessor); @@ -588,115 +576,65 @@ impl AirflowRole { remove_vector_shutdown_file_command(STACKABLE_LOG_DIR), ]; - if resolved_product_image.product_version.starts_with("3.") { - // Start-up commands have changed in 3.x. - // See https://airflow.apache.org/docs/apache-airflow/3.0.1/installation/upgrading_to_airflow3.html#step-6-changes-to-your-startup-scripts and - // https://airflow.apache.org/docs/apache-airflow/3.0.1/installation/setting-up-the-database.html#setting-up-the-database. - // `airflow db migrate` is not run for each role so there may be - // re-starts of webserver and/or workers (which require the DB). - // DB-migrations should be eventually be optional: - // See https://github.com/stackabletech/airflow-operator/issues/589. - match &self { - AirflowRole::Webserver => { - command.extend(Self::authentication_start_commands(auth_config)); - command.extend(vec![ - "prepare_signal_handlers".to_string(), - container_debug_command(), - format!( - "airflow api-server{} &", - self.proxy_headers_argument(cluster) - ), - ]); - } - AirflowRole::Scheduler => { - if database_initialization_enabled { - tracing::info!("Database initialization has been enabled."); - command.extend(vec![ - "airflow db migrate".to_string(), - CREATE_ADMIN_USER_COMMAND.to_string(), - ]); - } else { - tracing::info!("Database initialization routines have been skipped!") - } - command.extend(vec![ - "prepare_signal_handlers".to_string(), - container_debug_command(), - ]); - if !has_dag_processors { - // If no dag_processors role has been specified, the - // process needs to be included with the scheduler - // (with 3.x there is no longer the possibility of - // starting it as a subprocess, so it has to be - // explicitly started *somewhere*). - // It is started before the scheduler because the - // trailing `wait_for_termination $!` binds to the - // process that was backgrounded last, and that must be - // the scheduler. - command.extend(vec!["airflow dag-processor &".to_string()]); - } - command.extend(vec!["airflow scheduler &".to_string()]); - } - AirflowRole::DagProcessor => command.extend(vec![ - "prepare_signal_handlers".to_string(), - container_debug_command(), - "airflow dag-processor &".to_string(), - ]), - AirflowRole::Triggerer => command.extend(vec![ - "prepare_signal_handlers".to_string(), - container_debug_command(), - "airflow triggerer &".to_string(), - ]), - AirflowRole::Worker => command.extend(vec![ + // `airflow db migrate` is not run for each role so there may be + // re-starts of webserver and/or workers (which require the DB). + // DB-migrations should be eventually be optional: + // See https://github.com/stackabletech/airflow-operator/issues/589. + match &self { + AirflowRole::Webserver => { + command.extend(Self::authentication_start_commands(auth_config)); + command.extend(vec![ "prepare_signal_handlers".to_string(), container_debug_command(), - "airflow celery worker &".to_string(), - ]), + format!( + "airflow api-server{} &", + self.proxy_headers_argument(cluster) + ), + ]); } - } else { - match &self { - AirflowRole::Webserver => { - // Getting auth commands for AuthClass - command.extend(Self::authentication_start_commands(auth_config)); + AirflowRole::Scheduler => { + if database_initialization_enabled { + tracing::info!("Database initialization has been enabled."); command.extend(vec![ - "prepare_signal_handlers".to_string(), - container_debug_command(), - "airflow webserver &".to_string(), - ]); - } - AirflowRole::Scheduler => { - if database_initialization_enabled { - tracing::info!("Database initialization has been enabled."); - command.extend(vec![ - // Database initialization is limited to the scheduler, see https://github.com/stackabletech/airflow-operator/issues/259 - "airflow db init".to_string(), - "airflow db upgrade".to_string(), - CREATE_ADMIN_USER_COMMAND.to_string(), - ]); - } else { - tracing::info!("Database initialization routines have been skipped!") - } - command.extend(vec![ - "prepare_signal_handlers".to_string(), - container_debug_command(), - "airflow scheduler &".to_string(), + "airflow db migrate".to_string(), + CREATE_ADMIN_USER_COMMAND.to_string(), ]); + } else { + tracing::info!("Database initialization routines have been skipped!") } - AirflowRole::DagProcessor => command.extend(vec![ - "prepare_signal_handlers".to_string(), - container_debug_command(), - "airflow dag-processor &".to_string(), - ]), - AirflowRole::Triggerer => command.extend(vec![ + command.extend(vec![ "prepare_signal_handlers".to_string(), container_debug_command(), - "airflow triggerer &".to_string(), - ]), - AirflowRole::Worker => command.extend(vec![ - "prepare_signal_handlers".to_string(), - container_debug_command(), - "airflow celery worker &".to_string(), - ]), + ]); + if !has_dag_processors { + // If no dag_processors role has been specified, the + // process needs to be included with the scheduler + // (with 3.x there is no longer the possibility of + // starting it as a subprocess, so it has to be + // explicitly started *somewhere*). + // It is started before the scheduler because the + // trailing `wait_for_termination $!` binds to the + // process that was backgrounded last, and that must be + // the scheduler. + command.extend(vec!["airflow dag-processor &".to_string()]); + } + command.extend(vec!["airflow scheduler &".to_string()]); } + AirflowRole::DagProcessor => command.extend(vec![ + "prepare_signal_handlers".to_string(), + container_debug_command(), + "airflow dag-processor &".to_string(), + ]), + AirflowRole::Triggerer => command.extend(vec![ + "prepare_signal_handlers".to_string(), + container_debug_command(), + "airflow triggerer &".to_string(), + ]), + AirflowRole::Worker => command.extend(vec![ + "prepare_signal_handlers".to_string(), + container_debug_command(), + "airflow celery worker &".to_string(), + ]), } // graceful shutdown part @@ -710,7 +648,7 @@ impl AirflowRole { /// Add this CLI arg to enable proxy header support. /// Additional env vars are needed for the full functionality. - /// See `env_vars::add_version_specific_env_vars` for the counterpart function. + /// See `env_vars::add_core_env_vars` for the counterpart function. /// Only the webserver runs the api-server; every other role returns the empty string. fn proxy_headers_argument(&self, cluster: &ValidatedCluster) -> &'static str { if !matches!(self, AirflowRole::Webserver) { @@ -1164,10 +1102,6 @@ mod tests { fn every_role_backgrounds_its_own_process_last() { let cluster = validated_cluster("kubernetesExecutors", "{config: {}}"); - assert!( - cluster.image.product_version.starts_with("3."), - "the test cluster must run Airflow 3.x for this to test anything" - ); assert!(!cluster.has_role(&AirflowRole::DagProcessor)); for role in AirflowRole::iter() { diff --git a/rust/operator-binary/src/crd/trusted_proxies.rs b/rust/operator-binary/src/crd/trusted_proxies.rs index 35b9a82f..406085dd 100644 --- a/rust/operator-binary/src/crd/trusted_proxies.rs +++ b/rust/operator-binary/src/crd/trusted_proxies.rs @@ -53,12 +53,6 @@ pub enum Error { #[derive(Clone, Debug, Eq, PartialEq)] pub struct TrustedProxy(String); -impl TrustedProxy { - pub fn is_wildcard(&self) -> bool { - self.0 == WILDCARD - } -} - impl FromStr for TrustedProxy { type Err = Error; From 6e36264481c93799ed5ba3768f0a757c1ccc0510 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Tue, 24 Nov 2026 16:06:38 +0100 Subject: [PATCH 2/9] fix: Replace deprecated environment variable --- CHANGELOG.md | 7 +++++++ .../src/controller/build/properties/env_vars.rs | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4959db1..034cf35d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## [Unreleased] +### Fixed + +- Set `AIRFLOW__API__EXPOSE_CONFIG` instead of the deprecated + `AIRFLOW__WEBSERVER__EXPOSE_CONFIG`. Airflow 3 moved the option to the `[api]` section and only + still honours the old name through a deprecation shim, which logs a warning on every config + read ([#901]). + ### Removed - BREAKING: Remove the Airflow 2.x specific code paths ([#901]). diff --git a/rust/operator-binary/src/controller/build/properties/env_vars.rs b/rust/operator-binary/src/controller/build/properties/env_vars.rs index 7daa445a..9d75c247 100644 --- a/rust/operator-binary/src/controller/build/properties/env_vars.rs +++ b/rust/operator-binary/src/controller/build/properties/env_vars.rs @@ -53,7 +53,7 @@ constant!(AIRFLOW_FAB_UPDATE_FAB_PERMS: EnvVarName = "AIRFLOW__FAB__UPDATE_FAB_P constant!(FORWARDED_ALLOW_IPS: EnvVarName = "FORWARDED_ALLOW_IPS"); constant!(AIRFLOW_DATABASE_SQL_ALCHEMY_CONN: EnvVarName = "AIRFLOW__DATABASE__SQL_ALCHEMY_CONN"); -constant!(AIRFLOW_WEBSERVER_EXPOSE_CONFIG: EnvVarName = "AIRFLOW__WEBSERVER__EXPOSE_CONFIG"); +constant!(AIRFLOW_API_EXPOSE_CONFIG: EnvVarName = "AIRFLOW__API__EXPOSE_CONFIG"); constant!(AIRFLOW_CORE_EXECUTOR: EnvVarName = "AIRFLOW__CORE__EXECUTOR"); constant!(AIRFLOW_KUBERNETES_EXECUTOR_POD_TEMPLATE_FILE: EnvVarName = "AIRFLOW__KUBERNETES_EXECUTOR__POD_TEMPLATE_FILE"); @@ -136,7 +136,7 @@ pub fn build_airflow_statefulset_envs( ); if cluster.cluster_config.expose_config { - env_vars = env_vars.with_value(&AIRFLOW_WEBSERVER_EXPOSE_CONFIG, "True"); + env_vars = env_vars.with_value(&AIRFLOW_API_EXPOSE_CONFIG, "True"); } env_vars = env_vars.with_value(&AIRFLOW_CORE_EXECUTOR, executor.as_airflow_core_executor()); @@ -454,6 +454,7 @@ mod tests { let _ = *ADMIN_USERNAME_SECRET_KEY; let _ = *AIRFLOW_API_AUTH_BACKENDS; let _ = *AIRFLOW_API_AUTH_JWT_SECRET; + let _ = *AIRFLOW_API_EXPOSE_CONFIG; let _ = *AIRFLOW_API_SECRET_KEY; let _ = *AIRFLOW_API_WORKERS; let _ = *AIRFLOW_CELERY_BROKER_URL; @@ -476,7 +477,6 @@ mod tests { let _ = *AIRFLOW_METRICS_STATSD_HOST; let _ = *AIRFLOW_METRICS_STATSD_ON; let _ = *AIRFLOW_METRICS_STATSD_PORT; - let _ = *AIRFLOW_WEBSERVER_EXPOSE_CONFIG; let _ = *FORWARDED_ALLOW_IPS; let _ = *PYTHONPATH; let _ = *STACKABLE_POST_HOOK; From be86188bc5003e884c7dd0d153079dbdb1c5e077 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Wed, 25 Nov 2026 15:16:22 +0100 Subject: [PATCH 3/9] docs: Drop the stale DB-migration comment --- CHANGELOG.md | 7 ++++--- rust/operator-binary/src/crd/mod.rs | 7 +++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 034cf35d..a600fbbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,10 @@ ### Fixed - Set `AIRFLOW__API__EXPOSE_CONFIG` instead of the deprecated - `AIRFLOW__WEBSERVER__EXPOSE_CONFIG`. Airflow 3 moved the option to the `[api]` section and only - still honours the old name through a deprecation shim, which logs a warning on every config - read ([#901]). + `AIRFLOW__WEBSERVER__EXPOSE_CONFIG`. Airflow moved the option to the `[api]` section in 3.0.1 and + only still honours the old name through a deprecation shim, which logs a warning on every config + read. + See [Airflow's deprecated options table](https://github.com/apache/airflow/blob/3.3.2/shared/configuration/src/airflow_shared/configuration/parser.py#L261) for the move ([#901]). ### Removed diff --git a/rust/operator-binary/src/crd/mod.rs b/rust/operator-binary/src/crd/mod.rs index d665d068..3da2369e 100644 --- a/rust/operator-binary/src/crd/mod.rs +++ b/rust/operator-binary/src/crd/mod.rs @@ -576,10 +576,9 @@ impl AirflowRole { remove_vector_shutdown_file_command(STACKABLE_LOG_DIR), ]; - // `airflow db migrate` is not run for each role so there may be - // re-starts of webserver and/or workers (which require the DB). - // DB-migrations should be eventually be optional: - // See https://github.com/stackabletech/airflow-operator/issues/589. + // `airflow db migrate` only runs on the scheduler, and only when database + // initialization is enabled, so the webserver and the workers, which both need the + // database, may restart until the migration has completed. match &self { AirflowRole::Webserver => { command.extend(Self::authentication_start_commands(auth_config)); From b3a4dffd2ca448a6dac210007f7413921776daae Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Wed, 25 Nov 2026 15:33:58 +0100 Subject: [PATCH 4/9] docs: Drop the stale trusted-proxies version note --- extra/crds.yaml | 8 -------- rust/operator-binary/src/crd/mod.rs | 4 ---- 2 files changed, 12 deletions(-) diff --git a/extra/crds.yaml b/extra/crds.yaml index 1dda843f..4104221d 100644 --- a/extra/crds.yaml +++ b/extra/crds.yaml @@ -5853,10 +5853,6 @@ spec: only entry in the list if used: combining it with other entries is rejected, since it would silently degrade to trusting only those other entries. - On Airflow 3.x this restricts trust to the listed peers. On 2.x it only switches - forwarded-header handling on or off: any non-empty list trusts every peer, the same as - `*`, since Airflow 2.x has no way to restrict it further. - Leave this empty (the default) and forwarded headers are ignored entirely. items: type: string @@ -12234,10 +12230,6 @@ spec: only entry in the list if used: combining it with other entries is rejected, since it would silently degrade to trusting only those other entries. - On Airflow 3.x this restricts trust to the listed peers. On 2.x it only switches - forwarded-header handling on or off: any non-empty list trusts every peer, the same as - `*`, since Airflow 2.x has no way to restrict it further. - Leave this empty (the default) and forwarded headers are ignored entirely. items: type: string diff --git a/rust/operator-binary/src/crd/mod.rs b/rust/operator-binary/src/crd/mod.rs index 3da2369e..8748da8a 100644 --- a/rust/operator-binary/src/crd/mod.rs +++ b/rust/operator-binary/src/crd/mod.rs @@ -356,10 +356,6 @@ pub mod versioned { /// only entry in the list if used: combining it with other entries is rejected, since it /// would silently degrade to trusting only those other entries. /// - /// On Airflow 3.x this restricts trust to the listed peers. On 2.x it only switches - /// forwarded-header handling on or off: any non-empty list trusts every peer, the same as - /// `*`, since Airflow 2.x has no way to restrict it further. - /// /// Leave this empty (the default) and forwarded headers are ignored entirely. #[serde(default)] pub trusted_proxies: Vec, From 022cb3cd6b9bf93deaa664a56e82a395c28543a4 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Wed, 25 Nov 2026 15:46:36 +0100 Subject: [PATCH 5/9] refactor: Split the webserver env vars out of the core ones --- .../controller/build/properties/env_vars.rs | 61 ++++++++++--------- rust/operator-binary/src/crd/mod.rs | 2 +- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/rust/operator-binary/src/controller/build/properties/env_vars.rs b/rust/operator-binary/src/controller/build/properties/env_vars.rs index 9d75c247..1dfb1ba9 100644 --- a/rust/operator-binary/src/controller/build/properties/env_vars.rs +++ b/rust/operator-binary/src/controller/build/properties/env_vars.rs @@ -96,7 +96,7 @@ pub fn build_airflow_statefulset_envs( let internal_secret_name = cluster.internal_secret_name(); let mut env_vars = static_envs(git_sync_resources) - .merge(add_core_env_vars(cluster, airflow_role)) + .merge(core_env_vars(cluster)) // Replaces AIRFLOW__WEBSERVER__SECRET_KEY >= 3.0.2. .with_secret_key_ref( &AIRFLOW_API_SECRET_KEY, @@ -164,6 +164,7 @@ pub fn build_airflow_statefulset_envs( } AirflowRole::Webserver => { env_vars = env_vars + .merge(webserver_env_vars(cluster)) .merge(authentication_env_vars(auth_config)) .merge(authorization_env_vars(authorization_config)); } @@ -255,7 +256,7 @@ pub fn build_airflow_template_envs( .with_value(&AIRFLOW_KUBERNETES_EXECUTOR_NAMESPACE, &cluster.namespace) .with_value(&AIRFLOW_CORE_DAGS_FOLDER, dags_folder) .merge(static_envs(git_sync_resources)) - .merge(add_core_env_vars(cluster, &AirflowRole::Worker)); + .merge(core_env_vars(cluster)); // _STACKABLE_POST_HOOK will contain a command to create a shutdown hook that will be // evaluated in the wrapper for each stackable spark container: this is necessary for pods @@ -300,8 +301,10 @@ fn lineage_env_vars(cluster: &ValidatedCluster) -> EnvVarSet { /// Constructs the env vars that every Airflow role needs, independent of its role-specific /// configuration. -fn add_core_env_vars(cluster: &ValidatedCluster, airflow_role: &AirflowRole) -> EnvVarSet { - let mut env_vars = EnvVarSet::new() +/// +/// See `webserver_env_vars` for the ones only the api-server needs. +fn core_env_vars(cluster: &ValidatedCluster) -> EnvVarSet { + EnvVarSet::new() .merge(execution_server_env_vars(cluster)) .with_value( &AIRFLOW_CORE_AUTH_MANAGER, @@ -327,31 +330,33 @@ fn add_core_env_vars(cluster: &ValidatedCluster, airflow_role: &AirflowRole) -> // However, with the default resources this could cause problems, // as the Pod went to 100% CPU usage and didn't get healthy // quick enough, resulting in a crashloop. - .with_value(&AIRFLOW_API_WORKERS, "1"); - - if airflow_role == &AirflowRole::Webserver { - // Sometimes a race condition can arise when both scheduler and - // api-server are updating the DB, which adds overhead (conflicts - // are logged) and can result in inconsistencies. This setting - // ensure that only the scheduler will do this by default. - env_vars = env_vars.with_value(&AIRFLOW_FAB_UPDATE_FAB_PERMS, "False"); - - // This env var is needed in addition to `--proxy-headers` when Airflow runs - // behind a reverse proxy. - // This covers the uvicorn backend, the only one the SDP image can run. - let trusted_proxies = cluster - .trusted_proxies(airflow_role) - .iter() - .map(TrustedProxy::to_string) - .collect::>() - .join(","); - - if !trusted_proxies.is_empty() { - env_vars = env_vars.with_value(&FORWARDED_ALLOW_IPS, trusted_proxies); - } - } + .with_value(&AIRFLOW_API_WORKERS, "1") +} - env_vars +/// Constructs the env vars that only the webserver needs, because it is the role that runs the +/// api-server. +fn webserver_env_vars(cluster: &ValidatedCluster) -> EnvVarSet { + // Sometimes a race condition can arise when both scheduler and + // api-server are updating the DB, which adds overhead (conflicts + // are logged) and can result in inconsistencies. This setting + // ensure that only the scheduler will do this by default. + let env_vars = EnvVarSet::new().with_value(&AIRFLOW_FAB_UPDATE_FAB_PERMS, "False"); + + // This env var is needed in addition to `--proxy-headers` when Airflow runs + // behind a reverse proxy. + // This covers the uvicorn backend, the only one the SDP image can run. + let trusted_proxies = cluster + .trusted_proxies(&AirflowRole::Webserver) + .iter() + .map(TrustedProxy::to_string) + .collect::>() + .join(","); + + if trusted_proxies.is_empty() { + env_vars + } else { + env_vars.with_value(&FORWARDED_ALLOW_IPS, trusted_proxies) + } } fn authentication_env_vars(auth_config: &AirflowClientAuthenticationDetailsResolved) -> EnvVarSet { diff --git a/rust/operator-binary/src/crd/mod.rs b/rust/operator-binary/src/crd/mod.rs index 8748da8a..1d021ff2 100644 --- a/rust/operator-binary/src/crd/mod.rs +++ b/rust/operator-binary/src/crd/mod.rs @@ -643,7 +643,7 @@ impl AirflowRole { /// Add this CLI arg to enable proxy header support. /// Additional env vars are needed for the full functionality. - /// See `env_vars::add_core_env_vars` for the counterpart function. + /// See `env_vars::webserver_env_vars` for the counterpart function. /// Only the webserver runs the api-server; every other role returns the empty string. fn proxy_headers_argument(&self, cluster: &ValidatedCluster) -> &'static str { if !matches!(self, AirflowRole::Webserver) { From a910952d7500343b68f80dd461352919d0f62cb4 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Wed, 25 Nov 2026 15:57:53 +0100 Subject: [PATCH 6/9] test: Cover the expose-config env var name --- .../src/controller/build/mod.rs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rust/operator-binary/src/controller/build/mod.rs b/rust/operator-binary/src/controller/build/mod.rs index ea96ab24..6be28db0 100644 --- a/rust/operator-binary/src/controller/build/mod.rs +++ b/rust/operator-binary/src/controller/build/mod.rs @@ -716,6 +716,32 @@ mod tests { assert_eq!(env.get("FORWARDED_ALLOW_IPS"), None); } + /// Airflow moved `expose_config` from the `[webserver]` to the `[api]` section and only + /// honours the old name through a deprecation shim, which logs a warning on every config + /// read, so the operator must set the `[api]` variable. + #[test] + fn expose_config_sets_the_api_env_var() { + let mut cluster = celery_executor_cluster(); + cluster.cluster_config.expose_config = true; + let env = airflow_container_env(&cluster, "my-airflow-webserver-default"); + + assert_eq!( + env.get("AIRFLOW__API__EXPOSE_CONFIG"), + Some(&"True".to_owned()) + ); + assert_eq!(env.get("AIRFLOW__WEBSERVER__EXPOSE_CONFIG"), None); + } + + /// Airflow defaults `expose_config` to `False`, so the operator leaves the variable unset + /// rather than spelling the default out. + #[test] + fn no_expose_config_env_var_when_disabled() { + let cluster = celery_executor_cluster(); + let env = airflow_container_env(&cluster, "my-airflow-webserver-default"); + + assert_eq!(env.get("AIRFLOW__API__EXPOSE_CONFIG"), None); + } + /// A cluster with the given `spec.clusterConfig.volumeMounts` (as standalone YAML). fn cluster_with_user_volume_mounts( executor_key: &str, From 7712174399043eebda310b91b2b3654ed9c9fc68 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Wed, 25 Nov 2026 16:02:04 +0100 Subject: [PATCH 7/9] refactor: Inline the remote-task-log block into the template --- .../build/properties/product_logging/mod.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/rust/operator-binary/src/controller/build/properties/product_logging/mod.rs b/rust/operator-binary/src/controller/build/properties/product_logging/mod.rs index f34c409d..dbf0c9f6 100644 --- a/rust/operator-binary/src/controller/build/properties/product_logging/mod.rs +++ b/rust/operator-binary/src/controller/build/properties/product_logging/mod.rs @@ -72,13 +72,6 @@ LOGGING_CONFIG['loggers']['{name}']['level'] = {level} output }); - let remote_task_log = " -# This will cause the relevant RemoteLogIO handler to be initialized -REMOTE_TASK_LOG = airflow_local_settings.REMOTE_TASK_LOG -log = logging.getLogger(__name__) -log.info('Custom logging remote task log %s', REMOTE_TASK_LOG) -"; - format!( "\ import logging @@ -89,7 +82,12 @@ from airflow.config_templates import airflow_local_settings os.makedirs('{log_dir}', exist_ok=True) LOGGING_CONFIG = deepcopy(airflow_local_settings.DEFAULT_LOGGING_CONFIG) -{remote_task_log} + +# This will cause the relevant RemoteLogIO handler to be initialized +REMOTE_TASK_LOG = airflow_local_settings.REMOTE_TASK_LOG +log = logging.getLogger(__name__) +log.info('Custom logging remote task log %s', REMOTE_TASK_LOG) + LOGGING_CONFIG.setdefault('loggers', {{}}) for logger_name, logger_config in LOGGING_CONFIG['loggers'].items(): From c9c9fb1aed29f986ee8b7c5113e7a37cf577bbd4 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Wed, 25 Nov 2026 16:13:33 +0100 Subject: [PATCH 8/9] docs: Note the removed OPA config overrides in the changelog --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73849e32..390dcc1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,14 @@ ### Removed -- BREAKING: Remove the Airflow 2.x specific code paths ([#901]). +- BREAKING: Remove the Airflow 2.x specific code paths. + The OPA settings were the only ones that Airflow 2 read from `webserver_config.py`, so + `AUTH_OPA_REQUEST_URL`, `AUTH_OPA_CACHE_TTL_IN_SEC`, `AUTH_OPA_CACHE_MAXSIZE` and + `AUTH_OPA_REQUEST_TIMEOUT` are no longer known `configOverrides` keys for + `webserver_config.py`. Delete such entries. Unknown keys are written out verbatim, so a + left-over `AUTH_OPA_REQUEST_URL` renders as unquoted Python and the webserver fails to start. + Airflow 3 reads the OPA settings from the `AIRFLOW__CORE__AUTH_OPA_*` environment variables, + which the operator sets from `spec.clusterConfig.authorization.opa` ([#901]). [#901]: https://github.com/stackabletech/airflow-operator/pull/901 From 3092ee7b800d75cdd6bc3762a4ea816e22abda86 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Wed, 25 Nov 2026 16:17:02 +0100 Subject: [PATCH 9/9] docs: Drop the stale API-secret-key comment --- rust/operator-binary/src/controller/build/properties/env_vars.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/rust/operator-binary/src/controller/build/properties/env_vars.rs b/rust/operator-binary/src/controller/build/properties/env_vars.rs index 1dfb1ba9..1886bcd8 100644 --- a/rust/operator-binary/src/controller/build/properties/env_vars.rs +++ b/rust/operator-binary/src/controller/build/properties/env_vars.rs @@ -97,7 +97,6 @@ pub fn build_airflow_statefulset_envs( let mut env_vars = static_envs(git_sync_resources) .merge(core_env_vars(cluster)) - // Replaces AIRFLOW__WEBSERVER__SECRET_KEY >= 3.0.2. .with_secret_key_ref( &AIRFLOW_API_SECRET_KEY, &internal_secret_name,