Skip to content
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

### Added

- Add the `config.containerdebug` field to roles and role groups ([#899]).

[#899]: https://github.com/stackabletech/airflow-operator/pull/899

## [26.11.0] - 2026-11-20

## [26.11.0-rc1] - 2026-11-19
Expand Down
5 changes: 5 additions & 0 deletions docs/modules/airflow/pages/usage-guide/logging.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ spec:
vectorAggregatorConfigMapName: vector-aggregator-discovery
webservers:
config:
containerdebug:
enabled: false
logging:
enableVectorAgent: true
containers:
Expand Down Expand Up @@ -56,6 +58,9 @@ Overriding `FILE_LOG_DIRECTORY` with `envOverrides` therefore changes how these
The agent only collects files one level below `/stackable/log`, so a sibling directory such as `/stackable/log/airflow` relabels the events instead of dropping them, while any deeper or shallower path stops the aggregation.
A path outside `/stackable/log` also leaves the size-capped log volume.

The `containerdebug` process can be configured or turned off per role and role group, as described in xref:concepts:observability/containerdebug.adoc#configuration[].
Pods started by the Kubernetes executor do not run `containerdebug`, so `kubernetesExecutors` has no such setting.

Further information on how to configure logging, can be found in xref:concepts:logging.adoc[].

== Task logs
Expand Down
400 changes: 400 additions & 0 deletions extra/crds.yaml

Large diffs are not rendered by default.

48 changes: 47 additions & 1 deletion rust/operator-binary/src/controller/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,10 @@ mod tests {
use std::collections::BTreeMap;

use rstest::rstest;
use stackable_operator::kube::Resource;
use stackable_operator::{
crd::containerdebug::ValidatedContainerdebugConfig, kube::Resource, shared::time::Duration,
v2::product_logging::framework::STACKABLE_LOG_DIR,
};

use super::{
UNVERSIONED_PRODUCT_VERSION, build,
Expand Down Expand Up @@ -828,4 +831,47 @@ mod tests {
"unexpected error: {error:?}"
);
}

/// Each role group's StatefulSet starts `containerdebug` from that role group's merged config.
#[test]
fn stateful_sets_start_containerdebug_from_the_role_group_config() {
let cluster = validated_cluster_with("kubernetesExecutors", "{config: {}}", |cluster| {
cluster["spec"]["webservers"]["config"] =
yaml_serde::from_str("{containerdebug: {interval: 10m}}")
.expect("the webserver config is valid YAML");
cluster["spec"]["schedulers"]["roleGroups"]["default"]["config"] =
yaml_serde::from_str("{containerdebug: {enabled: false}}")
.expect("the scheduler role group config is valid YAML");
});
let resources = build(&cluster).expect("the resources build");

let containerdebug_line = |name: &str| {
resources
.stateful_sets
.iter()
.find(|stateful_set| stateful_set.meta().name.as_deref() == Some(name))
.and_then(|stateful_set| stateful_set.spec.as_ref())
.and_then(|spec| spec.template.spec.as_ref())
.expect("the StatefulSet has a pod spec")
.containers
.iter()
.find(|container| container.name == "airflow")
.and_then(|container| container.args.as_ref())
.expect("the airflow container has args")
.join("\n")
.lines()
.map(str::trim)
.find(|line| line.starts_with("containerdebug "))
.map(str::to_owned)
};

assert_eq!(
containerdebug_line("my-airflow-webserver-default"),
ValidatedContainerdebugConfig::Enabled {
interval: Duration::from_minutes_unchecked(10)
}
.background_command(STACKABLE_LOG_DIR)
);
assert_eq!(containerdebug_line("my-airflow-scheduler-default"), None);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ pub fn build_server_rolegroup_statefulset(
.context(GracefulShutdownSnafu)?;

let mut airflow_container_args = Vec::new();
airflow_container_args.extend(airflow_role.get_commands(validated_cluster));
airflow_container_args.extend(
airflow_role.get_commands(validated_cluster, &merged_airflow_config.containerdebug),
);

airflow_container
.image_from_product_image(resolved_product_image)
Expand Down
11 changes: 8 additions & 3 deletions rust/operator-binary/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use stackable_operator::{
resources::{NoRuntimeLimits, Resources},
},
constant,
crd::{git_sync, listener},
crd::{containerdebug::ValidatedContainerdebugConfig, git_sync, listener},
database_connections::{
TemplatingMechanism,
drivers::{
Expand Down Expand Up @@ -117,30 +117,34 @@ pub struct ValidatedAirflowConfig {
pub resources: Resources<AirflowStorageConfig, NoRuntimeLimits>,
pub logging: ValidatedLogging,
pub affinity: StackableAffinity,
pub containerdebug: ValidatedContainerdebugConfig,
pub graceful_shutdown_timeout: Option<Duration>,
pub git_sync_resources: git_sync::v1alpha2::GitSyncResources,
}

impl ValidatedAirflowConfig {
/// Builds the validated config from the merged [`AirflowConfig`], swapping in the
/// already-validated logging.
/// already-validated `containerdebug` and logging configuration.
pub(crate) fn from_merged(
merged: AirflowConfig,
containerdebug: ValidatedContainerdebugConfig,
logging: ValidatedLogging,
git_sync_resources: git_sync::v1alpha2::GitSyncResources,
) -> Self {
Self {
resources: merged.resources,
logging,
affinity: merged.affinity,
containerdebug,
graceful_shutdown_timeout: merged.graceful_shutdown_timeout,
git_sync_resources,
}
}

/// Builds the validated config from the merged [`ExecutorConfig`] (Kubernetes-executor pod
/// template), swapping in the already-validated logging. [`ExecutorConfig`] is field-identical
/// to [`AirflowConfig`].
/// to [`AirflowConfig`], except for `containerdebug`: executor pods don't run `containerdebug`,
/// so it is always disabled for them.
pub(crate) fn from_merged_executor(
merged: ExecutorConfig,
logging: ValidatedLogging,
Expand All @@ -150,6 +154,7 @@ impl ValidatedAirflowConfig {
resources: merged.resources,
logging,
affinity: merged.affinity,
containerdebug: ValidatedContainerdebugConfig::Disabled,
graceful_shutdown_timeout: merged.graceful_shutdown_timeout,
git_sync_resources,
}
Expand Down
103 changes: 100 additions & 3 deletions rust/operator-binary/src/controller/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use snafu::{OptionExt, ResultExt, Snafu};
use stackable_operator::{
commons::product_image_selection::{self, ResolvedProductImage},
config::fragment,
crd::git_sync,
crd::{containerdebug, git_sync},
k8s_openapi::api::core::v1::VolumeMount,
kube::ResourceExt,
product_logging::spec::Logging,
Expand All @@ -18,7 +18,7 @@ use stackable_operator::{
role_utils::{GenericCommonConfig, RoleGroup, RoleGroupConfig, with_validated_config},
types::{
kubernetes::ConfigMapName,
operator::{ClusterName, RoleGroupName},
operator::{ClusterName, RoleGroupName, RoleName},
},
},
};
Expand Down Expand Up @@ -77,6 +77,15 @@ pub enum Error {
role_group: RoleGroupName,
},

#[snafu(display(
"invalid containerdebug configuration for role {role} role group {role_group}"
))]
InvalidContainerdebugConfig {
source: containerdebug::Error,
role: RoleName,
role_group: RoleGroupName,
},

#[snafu(display("failed to validate the logging configuration"))]
ValidateLoggingConfig {
source: stackable_operator::v2::product_logging::framework::Error,
Expand Down Expand Up @@ -333,6 +342,7 @@ fn validate_role_groups(
})?;
let config = validate_role_group(
&resolved_role,
role,
&role_group_name,
rolegroup,
&default_config,
Expand All @@ -350,6 +360,7 @@ fn validate_role_groups(
#[allow(clippy::too_many_arguments)]
fn validate_role_group(
role: &AirflowRoleType,
airflow_role: &AirflowRole,
role_group_name: &RoleGroupName,
rolegroup: &RoleGroup<AirflowConfigFragment, GenericCommonConfig, AirflowConfigOverrides>,
default_config: &AirflowConfigFragment,
Expand All @@ -370,6 +381,12 @@ fn validate_role_group(
})?;

let merged_config = validated.config.config;
let containerdebug = merged_config.containerdebug.validate().with_context(|_| {
InvalidContainerdebugConfigSnafu {
role: (**airflow_role).clone(),
role_group: role_group_name.clone(),
}
})?;
let logging = validate_logging(
&merged_config.logging,
&Container::Airflow,
Expand All @@ -392,7 +409,12 @@ fn validate_role_group(

Ok(RoleGroupConfig {
replicas: validated.replicas,
config: ValidatedAirflowConfig::from_merged(merged_config, logging, git_sync_resources),
config: ValidatedAirflowConfig::from_merged(
merged_config,
containerdebug,
logging,
git_sync_resources,
),
config_overrides: validated.config.config_overrides,
env_overrides,
cli_overrides: validated.config.cli_overrides,
Expand Down Expand Up @@ -524,6 +546,7 @@ mod tests {

let validated = validate_role_group(
&role,
&AirflowRole::Webserver,
&"default".parse().expect("valid role group name"),
rolegroup,
&default_config,
Expand Down Expand Up @@ -622,6 +645,7 @@ mod tests {

let validated = validate_role_group(
&role,
&AirflowRole::Scheduler,
&"default".parse().expect("valid role group name"),
rolegroup,
&default_config,
Expand Down Expand Up @@ -699,6 +723,7 @@ mod tests {

let validated = validate_role_group(
&role,
&AirflowRole::Webserver,
&"default".parse().expect("valid role group name"),
rolegroup,
&default_config,
Expand Down Expand Up @@ -761,4 +786,76 @@ mod tests {
"error was: {error:?}"
);
}

/// [`test_cluster`] with the namespace and uid that `validate_cluster` resolves before it gets
/// to the role groups.
fn test_cluster_with_metadata() -> v1alpha2::AirflowCluster {
let mut cluster = test_cluster();
cluster.metadata.namespace = Some("default".to_owned());
cluster.metadata.uid = Some("e6ac237d-a6d4-43a1-8135-f36506110912".to_owned());
cluster
}

/// A role `config` that does not mention `containerdebug` still gets the default, so the
/// `containerdebug` field of the CRD must be optional.
#[test]
fn containerdebug_defaults_when_not_configured() {
use stackable_operator::crd::containerdebug::{
DEFAULT_INTERVAL, ValidatedContainerdebugConfig,
};

// The webservers of `test_cluster` have a `config: {}` without `containerdebug`.
let Ok(cluster) = validate_cluster(
&test_cluster_with_metadata(),
"oci.stackable.tech/sdp",
dereferenced_objects(),
) else {
panic!("the test cluster must validate");
};

assert_eq!(
cluster.webserver_role_group_configs
[&"default".parse().expect("valid role group name")]
.config
.containerdebug,
ValidatedContainerdebugConfig::Enabled {
interval: DEFAULT_INTERVAL
}
);
}

/// An invalid `containerdebug` config fails the validation, naming the role and role group.
#[test]
fn zero_containerdebug_interval_fails_validation() {
let mut cluster = test_cluster_with_metadata();
cluster
.spec
.schedulers
.as_mut()
.expect("the test CR declares a scheduler role")
.config
.config
.containerdebug
.interval = Some(stackable_operator::shared::time::Duration::from_secs(0));

let Err(error) =
validate_cluster(&cluster, "oci.stackable.tech/sdp", dereferenced_objects())
else {
panic!("the validation should fail");
};
let chain: Vec<String> =
std::iter::successors(Some(&error as &dyn std::error::Error), |error| {
error.source()
})
.map(ToString::to_string)
.collect();

assert_eq!(
chain,
[
"invalid containerdebug configuration for role scheduler role group default",
"the containerdebug interval must not be zero",
]
);
}
}
Loading
Loading