Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE/pre-release-rust-deps.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Bump Rust Dependencies for Stackable Release XX.(X)X
# Bump Rust Dependencies for Stackable Release YY.M.X

<!--
Make sure to update the link in 'issues/.github/ISSUE_TEMPLATE/pre-release-operator-rust-deps.md'
Expand Down Expand Up @@ -32,7 +32,7 @@ Part of <https://github.com/stackabletech/issues/issues/TRACKING_ISSUE>

```[tasklist]
### Bump Rust Dependencies
- [ ] Bump `stackable-operator` and friends.
- [ ] Bump `product-version`.
- [ ] Bump all other dependencies.
- [ ] Bump `stackable-operator` and friends
- [ ] Bump `product-config`
- [ ] Bump all other dependencies
```
9 changes: 6 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: '0'
CARGO_PROFILE_DEV_DEBUG: '0'
RUST_TOOLCHAIN_VERSION: "1.84.1"
RUST_TOOLCHAIN_VERSION: "1.85.0"
RUST_NIGHTLY_TOOLCHAIN_VERSION: "nightly-2025-01-15"
PYTHON_VERSION: "3.12"
RUSTFLAGS: "-D warnings"
RUSTDOCFLAGS: "-D warnings"
Expand Down Expand Up @@ -136,9 +137,11 @@ jobs:
submodules: recursive
- uses: dtolnay/rust-toolchain@c5a29ddb4d9d194e7c84ec8c3fba61b1c31fee8c
with:
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN_VERSION }}
components: rustfmt
- run: cargo fmt --all -- --check
- env:
RUST_TOOLCHAIN_VERSION: ${{ env.RUST_NIGHTLY_TOOLCHAIN_VERSION }}
run: cargo "+$RUST_TOOLCHAIN_VERSION" fmt --all -- --check

run_clippy:
name: Run Clippy
Expand Down
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"rust-analyzer.rustfmt.overrideCommand": [
"rustfmt",
"+nightly-2025-01-15",
"--"
],
}
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# DO NOT EDIT, this file is generated by operator-templating
[toolchain]
channel = "1.84.1"
channel = "1.85.0"
53 changes: 27 additions & 26 deletions rust/operator-binary/src/airflow_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use std::{

use const_format::concatcp;
use product_config::{
ProductConfigManager,
flask_app_config_writer::{self, FlaskAppConfigWriterError},
types::PropertyNameKind,
ProductConfigManager,
};
use snafu::{OptionExt, ResultExt, Snafu};
use stackable_operator::{
Expand All @@ -19,19 +19,19 @@ use stackable_operator::{
configmap::ConfigMapBuilder,
meta::ObjectMetaBuilder,
pod::{
container::ContainerBuilder, resources::ResourceRequirementsBuilder,
security::PodSecurityContextBuilder, volume::VolumeBuilder, PodBuilder,
PodBuilder, container::ContainerBuilder, resources::ResourceRequirementsBuilder,
security::PodSecurityContextBuilder, volume::VolumeBuilder,
},
},
cluster_resources::{ClusterResourceApplyStrategy, ClusterResources},
commons::{
authentication::{ldap, AuthenticationClass},
authentication::{AuthenticationClass, ldap},
product_image_selection::ResolvedProductImage,
rbac::build_rbac_resources,
},
config::fragment::ValidationError,
k8s_openapi::{
self,
self, DeepMerge,
api::{
apps::v1::{StatefulSet, StatefulSetSpec},
core::v1::{
Expand All @@ -40,19 +40,18 @@ use stackable_operator::{
},
},
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
DeepMerge,
},
kube::{
Resource, ResourceExt,
api::ObjectMeta,
core::{error_boundary, DeserializeGuard},
core::{DeserializeGuard, error_boundary},
runtime::{controller::Action, reflector::ObjectRef},
Resource, ResourceExt,
},
kvp::{Label, LabelError, Labels},
logging::controller::ReconcilerError,
product_config_utils::{
transform_all_roles_to_config, validate_all_roles_and_groups_config,
CONFIG_OVERRIDE_FILE_FOOTER_KEY, CONFIG_OVERRIDE_FILE_HEADER_KEY,
transform_all_roles_to_config, validate_all_roles_and_groups_config,
},
product_logging::{
self,
Expand All @@ -75,17 +74,17 @@ use crate::{
config::{self, PYTHON_IMPORTS},
controller_commons::{self, CONFIG_VOLUME_NAME, LOG_CONFIG_VOLUME_NAME, LOG_VOLUME_NAME},
crd::{
self,
self, AIRFLOW_CONFIG_FILENAME, AIRFLOW_UID, APP_NAME, AirflowClusterStatus, AirflowConfig,
AirflowConfigOptions, AirflowExecutor, AirflowRole, CONFIG_PATH, Container, ExecutorConfig,
ExecutorConfigFragment, LOG_CONFIG_DIR, OPERATOR_NAME, STACKABLE_LOG_DIR,
TEMPLATE_CONFIGMAP_NAME, TEMPLATE_LOCATION, TEMPLATE_NAME, TEMPLATE_VOLUME_NAME,
authentication::{
AirflowAuthenticationClassResolved, AirflowClientAuthenticationDetailsResolved,
},
authorization::AirflowAuthorizationResolved,
build_recommended_labels,
git_sync::{GitSync, GIT_SYNC_CONTENT, GIT_SYNC_NAME, GIT_SYNC_ROOT},
v1alpha1, AirflowClusterStatus, AirflowConfig, AirflowConfigOptions, AirflowExecutor,
AirflowRole, Container, ExecutorConfig, ExecutorConfigFragment, AIRFLOW_CONFIG_FILENAME,
AIRFLOW_UID, APP_NAME, CONFIG_PATH, LOG_CONFIG_DIR, OPERATOR_NAME, STACKABLE_LOG_DIR,
TEMPLATE_CONFIGMAP_NAME, TEMPLATE_LOCATION, TEMPLATE_NAME, TEMPLATE_VOLUME_NAME,
git_sync::{GIT_SYNC_CONTENT, GIT_SYNC_NAME, GIT_SYNC_ROOT, GitSync},
v1alpha1,
},
env_vars::{
self, build_airflow_template_envs, build_gitsync_statefulset_envs, build_gitsync_template,
Expand Down Expand Up @@ -552,10 +551,10 @@ pub async fn reconcile_airflow(
.context(DeleteOrphanedResourcesSnafu)?;

let status = AirflowClusterStatus {
conditions: compute_conditions(
airflow,
&[&ss_cond_builder, &cluster_operation_cond_builder],
),
conditions: compute_conditions(airflow, &[
&ss_cond_builder,
&cluster_operation_cond_builder,
]),
};

client
Expand Down Expand Up @@ -1001,13 +1000,15 @@ fn build_server_rolegroup_statefulset(
"pipefail".to_string(),
"-c".to_string(),
])
.args(vec![[
COMMON_BASH_TRAP_FUNCTIONS.to_string(),
"prepare_signal_handlers".to_string(),
"/stackable/statsd_exporter &".to_string(),
"wait_for_termination $!".to_string(),
]
.join("\n")])
.args(vec![
[
COMMON_BASH_TRAP_FUNCTIONS.to_string(),
"prepare_signal_handlers".to_string(),
"/stackable/statsd_exporter &".to_string(),
"wait_for_termination $!".to_string(),
]
.join("\n"),
])
.add_container_port(METRICS_PORT_NAME, METRICS_PORT)
.resources(
ResourceRequirementsBuilder::new()
Expand Down
15 changes: 6 additions & 9 deletions rust/operator-binary/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use stackable_operator::commons::{
};

use crate::crd::{
AirflowConfigOptions,
authentication::{
AirflowAuthenticationClassResolved, AirflowClientAuthenticationDetailsResolved,
FlaskRolesSyncMoment, DEFAULT_OIDC_PROVIDER,
DEFAULT_OIDC_PROVIDER, FlaskRolesSyncMoment,
},
authorization::{AirflowAuthorizationResolved, OpaConfigResolved},
AirflowConfigOptions,
};

pub const PYTHON_IMPORTS: &[&str] = &[
Expand Down Expand Up @@ -324,8 +324,8 @@ mod tests {
config::add_airflow_config,
crd::{
authentication::{
default_user_registration, AirflowAuthenticationClassResolved,
AirflowClientAuthenticationDetailsResolved, FlaskRolesSyncMoment,
AirflowAuthenticationClassResolved, AirflowClientAuthenticationDetailsResolved,
FlaskRolesSyncMoment, default_user_registration,
},
authorization::{AirflowAuthorizationResolved, OpaConfigResolved},
},
Expand Down Expand Up @@ -482,9 +482,7 @@ mod tests {
("AUTH_TYPE".into(), "AUTH_OAUTH".into()),
("AUTH_USER_REGISTRATION".into(), "true".into()),
("AUTH_USER_REGISTRATION_ROLE".into(), "Admin".into()),
(
"OAUTH_PROVIDERS".into(),
formatdoc! {"
("OAUTH_PROVIDERS".into(), formatdoc! {"
[
{{ 'name': 'keycloak',
'icon': 'fa-key',
Expand Down Expand Up @@ -513,8 +511,7 @@ mod tests {
}},
}}
]
"}
)
"})
]),
result
);
Expand Down
6 changes: 3 additions & 3 deletions rust/operator-binary/src/crd/affinity.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use stackable_operator::{
commons::affinity::{
affinity_between_cluster_pods, affinity_between_role_pods, StackableAffinityFragment,
StackableAffinityFragment, affinity_between_cluster_pods, affinity_between_role_pods,
},
k8s_openapi::api::core::v1::{PodAffinity, PodAntiAffinity},
};

use crate::crd::{AirflowRole, APP_NAME};
use crate::crd::{APP_NAME, AirflowRole};

/// Used for all [`AirflowRole`]s besides executors.
pub fn get_affinity(cluster_name: &str, role: &AirflowRole) -> StackableAffinityFragment {
Expand Down Expand Up @@ -55,7 +55,7 @@ mod tests {
role_utils::RoleGroupRef,
};

use crate::crd::{v1alpha1, AirflowExecutor, AirflowRole};
use crate::crd::{AirflowExecutor, AirflowRole, v1alpha1};

#[rstest]
#[case(AirflowRole::Worker)]
Expand Down
21 changes: 14 additions & 7 deletions rust/operator-binary/src/crd/authentication.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use std::{collections::BTreeSet, future::Future, mem};

use serde::{Deserialize, Serialize};
use snafu::{ensure, ResultExt, Snafu};
use snafu::{ResultExt, Snafu, ensure};
use stackable_operator::{
client::Client,
commons::authentication::{
ldap,
AuthenticationClass, AuthenticationClassProvider, ClientAuthenticationDetails, ldap,
oidc::{self, IdentityProviderHint},
AuthenticationClass, AuthenticationClassProvider, ClientAuthenticationDetails,
},
schemars::{self, JsonSchema},
};
Expand Down Expand Up @@ -40,11 +39,15 @@ pub enum Error {
auth_class_name: String,
provider: String,
},
#[snafu(display("Only one authentication type at a time is supported by Airflow, see https://github.com/dpgaspar/Flask-AppBuilder/issues/1924."))]
#[snafu(display(
"Only one authentication type at a time is supported by Airflow, see https://github.com/dpgaspar/Flask-AppBuilder/issues/1924."
))]
MultipleAuthenticationTypesNotSupported,
#[snafu(display("Only one LDAP provider at a time is supported by Airflow."))]
MultipleLdapProvidersNotSupported,
#[snafu(display("The OIDC provider {oidc_provider:?} is not yet supported (AuthenticationClass {auth_class_name:?})."))]
#[snafu(display(
"The OIDC provider {oidc_provider:?} is not yet supported (AuthenticationClass {auth_class_name:?})."
))]
OidcProviderNotSupported {
auth_class_name: String,
oidc_provider: String,
Expand Down Expand Up @@ -147,6 +150,7 @@ impl AirflowClientAuthenticationDetailsResolved {
};
AirflowClientAuthenticationDetailsResolved::resolve(auth_details, resolve_auth_class).await
}

pub async fn resolve<R>(
auth_details: &[AirflowClientAuthenticationDetails],
resolve_auth_class: impl Fn(ClientAuthenticationDetails) -> R,
Expand Down Expand Up @@ -264,8 +268,11 @@ impl AirflowClientAuthenticationDetailsResolved {
) -> Result<AirflowAuthenticationClassResolved> {
let oidc_provider = match &provider.provider_hint {
None => {
info!("No OIDC provider hint given in AuthClass {auth_class_name}, assuming {default_oidc_provider_name}",
default_oidc_provider_name = serde_json::to_string(&DEFAULT_OIDC_PROVIDER).unwrap());
info!(
"No OIDC provider hint given in AuthClass {auth_class_name}, assuming {default_oidc_provider_name}",
default_oidc_provider_name =
serde_json::to_string(&DEFAULT_OIDC_PROVIDER).unwrap()
);
DEFAULT_OIDC_PROVIDER
}
Some(oidc_provider) => oidc_provider.to_owned(),
Expand Down
2 changes: 1 addition & 1 deletion rust/operator-binary/src/crd/authorization.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use stackable_operator::{client::Client, commons::opa::OpaApiVersion, time::Duration};

use crate::crd::{v1alpha1, AirflowAuthorization, AirflowOpaConfig};
use crate::crd::{AirflowAuthorization, AirflowOpaConfig, v1alpha1};

pub struct AirflowAuthorizationResolved {
pub opa: Option<OpaConfigResolved>,
Expand Down
18 changes: 10 additions & 8 deletions rust/operator-binary/src/crd/git_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ mod tests {
"--git-config='safe.directory:/tmp/git,http.sslCAInfo:/tmp/ca-cert/ca.crt'"
)]
#[case(
"--git-config: 'http.sslCAInfo:/tmp/ca-cert/ca.crt,safe.directory:/tmp/git2'",
"--git-config='safe.directory:/tmp/git,http.sslCAInfo:/tmp/ca-cert/ca.crt,safe.directory:/tmp/git2'"
"--git-config: 'http.sslCAInfo:/tmp/ca-cert/ca.crt,safe.directory:/tmp/git2'",
"--git-config='safe.directory:/tmp/git,http.sslCAInfo:/tmp/ca-cert/ca.crt,safe.directory:/tmp/git2'"
)]
fn test_git_sync_git_config(#[case] input: &str, #[case] output: &str) {
let cluster = format!(
Expand Down Expand Up @@ -317,11 +317,13 @@ mod tests {
let cluster: AirflowCluster =
serde_yaml::with::singleton_map_recursive::deserialize(deserializer).unwrap();

assert!(cluster
.git_sync()
.unwrap()
.get_args(false)
.iter()
.any(|c| c.contains(output)));
assert!(
cluster
.git_sync()
.unwrap()
.get_args(false)
.iter()
.any(|c| c.contains(output))
);
}
}
16 changes: 11 additions & 5 deletions rust/operator-binary/src/crd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use stackable_operator::{
schemars::{self, JsonSchema},
status::condition::{ClusterCondition, HasStatusCondition},
time::Duration,
utils::{crds::raw_object_list_schema, COMMON_BASH_TRAP_FUNCTIONS},
utils::{COMMON_BASH_TRAP_FUNCTIONS, crds::raw_object_list_schema},
};
use stackable_versioned::versioned;
use strum::{Display, EnumIter, EnumString, IntoEnumIterator};
Expand All @@ -50,7 +50,7 @@ use crate::crd::{
AirflowAuthenticationClassResolved, AirflowClientAuthenticationDetails,
AirflowClientAuthenticationDetailsResolved,
},
git_sync::{GitSync, GIT_SYNC_CONTENT, GIT_SYNC_DIR},
git_sync::{GIT_SYNC_CONTENT, GIT_SYNC_DIR, GitSync},
};

pub mod affinity;
Expand Down Expand Up @@ -520,7 +520,9 @@ impl AirflowRole {
auth_config: &AirflowClientAuthenticationDetailsResolved,
) -> Vec<String> {
let mut command = vec![
format!("cp -RL {CONFIG_PATH}/{AIRFLOW_CONFIG_FILENAME} {AIRFLOW_HOME}/{AIRFLOW_CONFIG_FILENAME}"),
format!(
"cp -RL {CONFIG_PATH}/{AIRFLOW_CONFIG_FILENAME} {AIRFLOW_HOME}/{AIRFLOW_CONFIG_FILENAME}"
),
// graceful shutdown part
COMMON_BASH_TRAP_FUNCTIONS.to_string(),
remove_vector_shutdown_file_command(STACKABLE_LOG_DIR),
Expand Down Expand Up @@ -550,12 +552,16 @@ impl AirflowRole {
--role \"Admin\""
.to_string(),
"prepare_signal_handlers".to_string(),
format!("containerdebug --output={STACKABLE_LOG_DIR}/containerdebug-state.json --loop &"),
format!(
"containerdebug --output={STACKABLE_LOG_DIR}/containerdebug-state.json --loop &"
),
"airflow scheduler &".to_string(),
]),
AirflowRole::Worker => command.extend(vec![
"prepare_signal_handlers".to_string(),
format!("containerdebug --output={STACKABLE_LOG_DIR}/containerdebug-state.json --loop &"),
format!(
"containerdebug --output={STACKABLE_LOG_DIR}/containerdebug-state.json --loop &"
),
"airflow celery worker &".to_string(),
]),
}
Expand Down
Loading
Loading