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 @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

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

[#1023]: https://github.com/stackabletech/nifi-operator/pull/1023

## [26.11.0] - 2026-11-20

## [26.11.0-rc1] - 2026-11-19
Expand Down
4 changes: 4 additions & 0 deletions docs/modules/nifi/pages/usage_guide/log-aggregation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ spec:
vectorAggregatorConfigMapName: vector-aggregator-discovery
nodes:
config:
containerdebug:
enabled: false
logging:
enableVectorAgent: true
----
Expand All @@ -22,4 +24,6 @@ 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/nifi` 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[].

Further information on how to configure logging, can be found in xref:concepts:logging.adoc[].
40 changes: 40 additions & 0 deletions extra/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,26 @@ spec:
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
containerdebug:
default:
enabled: null
interval: null
description: |-
Configures the `containerdebug` tool, which periodically logs information about the container
environment (such as network interfaces, DNS lookups and disk usage) in the background of the
product container.
properties:
enabled:
description: Whether `containerdebug` runs in the background of the product container. Defaults to `true`.
nullable: true
type: boolean
interval:
description: |-
Time between two runs of `containerdebug`, e.g. `30m`, `1h` or `2d`. Must not be zero.
Defaults to `30m`.
nullable: true
type: string
type: object
gracefulShutdownTimeout:
description: Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the operator documentation for details.
nullable: true
Expand Down Expand Up @@ -1427,6 +1447,26 @@ spec:
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
containerdebug:
default:
enabled: null
interval: null
description: |-
Configures the `containerdebug` tool, which periodically logs information about the container
environment (such as network interfaces, DNS lookups and disk usage) in the background of the
product container.
properties:
enabled:
description: Whether `containerdebug` runs in the background of the product container. Defaults to `true`.
nullable: true
type: boolean
interval:
description: |-
Time between two runs of `containerdebug`, e.g. `30m`, `1h` or `2d`. Must not be zero.
Defaults to `30m`.
nullable: true
type: string
type: object
gracefulShutdownTimeout:
description: Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the operator documentation for details.
nullable: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,30 @@ pub fn build(rg: &NifiRoleGroupConfig) -> Result<String, PropertiesWriterError>
mod tests {
use std::collections::BTreeMap;

use stackable_operator::v2::{
builder::pod::container::EnvVarSet, config_overrides::KeyValueConfigOverrides,
use stackable_operator::{
config::fragment,
v2::{builder::pod::container::EnvVarSet, config_overrides::KeyValueConfigOverrides},
};

use super::*;
use crate::{
controller::ValidatedNifiConfig,
crd::{NifiConfig, v1alpha1::NifiConfigOverrides},
crd::{NifiConfig, NifiRole, v1alpha1::NifiConfigOverrides},
};

fn make_rg(overrides: Option<BTreeMap<String, String>>) -> NifiRoleGroupConfig {
use stackable_operator::v2::role_utils::JavaCommonConfig;

NifiRoleGroupConfig {
replicas: Some(1),
config: ValidatedNifiConfig::from_merged_for_test(NifiConfig::default()),
config: ValidatedNifiConfig::from_merged_for_test(
fragment::validate(NifiConfig::default_config(
"simple-nifi",
&NifiRole::Node,
None,
))
.expect("the default config is complete"),
),
config_overrides: NifiConfigOverrides {
security_properties: KeyValueConfigOverrides {
overrides: overrides.unwrap_or_default(),
Expand Down
60 changes: 58 additions & 2 deletions rust/operator-binary/src/controller/build/resource/statefulset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,18 @@ pub(crate) fn build_node_rolegroup_statefulset(
{remove_vector_shutdown_file_command}
prepare_signal_handlers
mkdir --parents \"${file_log_directory}\" || true
containerdebug --output={STACKABLE_LOG_DIR}/containerdebug-state.json --loop &
{containerdebug_command}
bin/nifi.sh run &
wait_for_termination $!
{create_vector_shutdown_file_command}
",
remove_vector_shutdown_file_command =
remove_vector_shutdown_file_command(STACKABLE_LOG_DIR),
file_log_directory = FILE_LOG_DIRECTORY_ENV.as_ref(),
containerdebug_command = merged_config
.containerdebug
.background_command(STACKABLE_LOG_DIR)
.unwrap_or_default(),
create_vector_shutdown_file_command =
create_vector_shutdown_file_command(STACKABLE_LOG_DIR),
}];
Expand Down Expand Up @@ -783,9 +787,14 @@ fn get_volume_claim_templates(

#[cfg(test)]
mod tests {
use rstest::rstest;
use stackable_operator::{
crd::containerdebug::ValidatedContainerdebugConfig, shared::time::Duration,
};

use super::*;
use crate::controller::build::properties::test_support::{
default_rg, validated_cluster_from_yaml,
default_rg, minimal_validated_cluster, validated_cluster_from_yaml,
};

#[test]
Expand Down Expand Up @@ -921,4 +930,51 @@ mod tests {
"unexpected error: {error:?}"
);
}

/// The nifi container starts `containerdebug` from the role group's validated config. The
/// command itself is owned (and tested) by operator-rs, so only the wiring is checked here.
#[rstest]
#[case::enabled(ValidatedContainerdebugConfig::Enabled {
interval: Duration::from_minutes_unchecked(10)
})]
#[case::disabled(ValidatedContainerdebugConfig::Disabled)]
fn nifi_container_starts_containerdebug_from_config(
#[case] containerdebug: ValidatedContainerdebugConfig,
) {
let expected = containerdebug.background_command(STACKABLE_LOG_DIR);
let mut cluster = minimal_validated_cluster();
let role_group_name = RoleGroupName::from_str("default").expect("valid role group name");
cluster
.role_group_configs
.get_mut(&NifiRole::Node)
.and_then(|role_groups| role_groups.get_mut(&role_group_name))
.expect("the default role group exists")
.config
.containerdebug = containerdebug;
let rg = default_rg(&cluster);

let stateful_set = build_node_rolegroup_statefulset(&cluster, &role_group_name, rg, None)
.expect("the StatefulSet builds");

let args = stateful_set
.spec
.expect("the StatefulSet has a spec")
.template
.spec
.expect("the pod template has a spec")
.containers
.into_iter()
.find(|container| container.name == NIFI_CONTAINER_NAME.to_string())
.expect("the nifi container exists")
.args
.expect("the nifi container has args")
.join("\n");
assert_eq!(
args.lines()
.map(str::trim)
.find(|line| line.starts_with("containerdebug ")),
expected.as_deref(),
"args: {args}"
);
}
}
12 changes: 11 additions & 1 deletion rust/operator-binary/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use stackable_operator::{
resources::{NoRuntimeLimits, Resources},
},
constant,
crd::{git_sync, listener},
crd::{containerdebug::ValidatedContainerdebugConfig, git_sync, listener},
k8s_openapi::{
api::{
apps::v1::StatefulSet,
Expand Down Expand Up @@ -100,6 +100,8 @@ pub struct ValidatedNifiConfig {
pub resources: Resources<NifiStorageConfig, NoRuntimeLimits>,
/// Pod (anti-)affinity for the role group.
pub affinity: StackableAffinity,
/// The validated `containerdebug` configuration.
pub containerdebug: ValidatedContainerdebugConfig,
/// Time period Pods have to gracefully shut down.
pub graceful_shutdown_timeout: Option<Duration>,
/// Requested lifetime of the auto-TLS secret.
Expand All @@ -117,12 +119,14 @@ pub struct ValidatedNifiConfig {
impl ValidatedNifiConfig {
pub(crate) fn from_merged(
merged: NifiConfig,
containerdebug: ValidatedContainerdebugConfig,
logging: ValidatedLogging,
git_sync_resources: git_sync::v1alpha2::GitSyncResources,
) -> Self {
Self {
resources: merged.resources,
affinity: merged.affinity,
containerdebug,
graceful_shutdown_timeout: merged.graceful_shutdown_timeout,
requested_secret_lifetime: merged.requested_secret_lifetime,
logging,
Expand All @@ -134,8 +138,14 @@ impl ValidatedNifiConfig {
pub(crate) fn from_merged_for_test(merged: NifiConfig) -> Self {
use stackable_operator::product_logging::spec::AutomaticContainerLogConfig;

let containerdebug = merged
.containerdebug
.validate()
.expect("the containerdebug config is valid");

Self::from_merged(
merged,
containerdebug,
ValidatedLogging {
nifi_container: ValidatedContainerLogConfigChoice::Automatic(
AutomaticContainerLogConfig::default(),
Expand Down
Loading
Loading