diff --git a/CHANGELOG.md b/CHANGELOG.md index 43ef5f73..8d04a23a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ([#907]). + +[#907]: https://github.com/stackabletech/druid-operator/pull/907 + ## [26.11.0] - 2026-11-20 ## [26.11.0-rc1] - 2026-11-19 diff --git a/docs/modules/druid/pages/usage-guide/logging.adoc b/docs/modules/druid/pages/usage-guide/logging.adoc index c07c2fc7..4f6997a6 100644 --- a/docs/modules/druid/pages/usage-guide/logging.adoc +++ b/docs/modules/druid/pages/usage-guide/logging.adoc @@ -10,6 +10,8 @@ spec: vectorAggregatorConfigMapName: vector-aggregator-discovery brokers: config: + containerdebug: + enabled: false logging: enableVectorAgent: true coordinators: @@ -38,4 +40,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/druid` 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[]. diff --git a/extra/crds.yaml b/extra/crds.yaml index b988373f..b9aa18fd 100644 --- a/extra/crds.yaml +++ b/extra/crds.yaml @@ -74,6 +74,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: |- The time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. @@ -569,6 +589,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: |- The time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. @@ -1705,6 +1745,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: |- The time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. @@ -2200,6 +2260,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: |- The time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. @@ -2682,6 +2762,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: |- The time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. @@ -3214,6 +3314,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: |- The time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. @@ -3839,6 +3959,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: |- The time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. @@ -4327,6 +4467,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: |- The time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. @@ -4823,6 +4983,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: |- The time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. @@ -5318,6 +5498,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: |- The time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. diff --git a/rust/operator-binary/src/controller/build/container.rs b/rust/operator-binary/src/controller/build/container.rs index d07ee0e5..3b049611 100644 --- a/rust/operator-binary/src/controller/build/container.rs +++ b/rust/operator-binary/src/controller/build/container.rs @@ -287,7 +287,7 @@ pub(crate) fn containers_and_volumes(inputs: &RoleGroupInputs) -> Result( resources, logging, affinity, + containerdebug, graceful_shutdown_timeout, requested_secret_lifetime, } = &rg_config.config; @@ -45,6 +46,7 @@ pub(crate) fn build<'a>( heap, direct_memory: Some(direct_memory), logging: logging.clone(), + containerdebug: containerdebug.clone(), listener: Some(group_listener_name(&cluster.name, &ROLE)), role_pod_volumes: Vec::new(), role_druid_mounts: Vec::new(), diff --git a/rust/operator-binary/src/controller/build/role_group/coordinator.rs b/rust/operator-binary/src/controller/build/role_group/coordinator.rs index 122df8c1..73d83ae3 100644 --- a/rust/operator-binary/src/controller/build/role_group/coordinator.rs +++ b/rust/operator-binary/src/controller/build/role_group/coordinator.rs @@ -34,6 +34,7 @@ pub(crate) fn build<'a>( resources, logging, affinity, + containerdebug, graceful_shutdown_timeout, requested_secret_lifetime, } = &rg_config.config; @@ -52,6 +53,7 @@ pub(crate) fn build<'a>( heap, direct_memory: None, logging: logging.clone(), + containerdebug: containerdebug.clone(), listener: Some(group_listener_name(&cluster.name, &ROLE)), role_pod_volumes: Vec::new(), role_druid_mounts: Vec::new(), diff --git a/rust/operator-binary/src/controller/build/role_group/historical.rs b/rust/operator-binary/src/controller/build/role_group/historical.rs index 9fe13b18..a3cf2562 100644 --- a/rust/operator-binary/src/controller/build/role_group/historical.rs +++ b/rust/operator-binary/src/controller/build/role_group/historical.rs @@ -33,6 +33,7 @@ pub(crate) fn build<'a>( resources, logging, affinity, + containerdebug, graceful_shutdown_timeout, requested_secret_lifetime, } = &rg_config.config; @@ -59,6 +60,7 @@ pub(crate) fn build<'a>( heap: derived_settings.heap_memory(), direct_memory: Some(derived_settings.direct_access_memory()), logging: logging.clone(), + containerdebug: containerdebug.clone(), listener: None, role_pod_volumes: vec![segment_cache_volume(segment_cache)], role_druid_mounts: vec![segment_cache_volume_mount()], diff --git a/rust/operator-binary/src/controller/build/role_group/middle_manager.rs b/rust/operator-binary/src/controller/build/role_group/middle_manager.rs index 9a078792..27d02c63 100644 --- a/rust/operator-binary/src/controller/build/role_group/middle_manager.rs +++ b/rust/operator-binary/src/controller/build/role_group/middle_manager.rs @@ -138,6 +138,7 @@ pub(crate) fn build<'a>( resources, logging, affinity, + containerdebug, graceful_shutdown_timeout, requested_secret_lifetime, } = &rg_config.config; @@ -156,6 +157,7 @@ pub(crate) fn build<'a>( heap, direct_memory: None, logging: logging.clone(), + containerdebug: containerdebug.clone(), listener: None, role_pod_volumes: Vec::new(), role_druid_mounts: Vec::new(), diff --git a/rust/operator-binary/src/controller/build/role_group/mod.rs b/rust/operator-binary/src/controller/build/role_group/mod.rs index a5ed5900..4c5459f3 100644 --- a/rust/operator-binary/src/controller/build/role_group/mod.rs +++ b/rust/operator-binary/src/controller/build/role_group/mod.rs @@ -18,6 +18,7 @@ use std::collections::BTreeMap; use snafu::{ResultExt, Snafu}; use stackable_operator::{ commons::affinity::StackableAffinity, + crd::containerdebug::ValidatedContainerdebugConfig, k8s_openapi::api::{ apps::v1::StatefulSet, core::v1::{ @@ -89,6 +90,8 @@ pub(crate) struct RoleGroupInputs<'a> { /// Router. pub(crate) direct_memory: Option, pub(crate) logging: ValidatedLogging, + /// Starts (or not) the `containerdebug` process in the background of the `druid` container. + pub(crate) containerdebug: ValidatedContainerdebugConfig, /// The role's group Listener name; `Some` for Brokers, Coordinators and Routers. Drives the /// listener claim template, its mount on the `druid` container and the listener scope of the /// TLS volume. diff --git a/rust/operator-binary/src/controller/build/role_group/router.rs b/rust/operator-binary/src/controller/build/role_group/router.rs index 1f58d01e..7cce4c52 100644 --- a/rust/operator-binary/src/controller/build/role_group/router.rs +++ b/rust/operator-binary/src/controller/build/role_group/router.rs @@ -26,6 +26,7 @@ pub(crate) fn build<'a>( resources, logging, affinity, + containerdebug, graceful_shutdown_timeout, requested_secret_lifetime, } = &rg_config.config; @@ -45,6 +46,7 @@ pub(crate) fn build<'a>( heap, direct_memory: Some(direct_memory), logging: logging.clone(), + containerdebug: containerdebug.clone(), listener: Some(group_listener_name(&cluster.name, &ROLE)), role_pod_volumes: Vec::new(), role_druid_mounts: Vec::new(), diff --git a/rust/operator-binary/src/controller/validate.rs b/rust/operator-binary/src/controller/validate.rs index ef332cb7..623ea881 100644 --- a/rust/operator-binary/src/controller/validate.rs +++ b/rust/operator-binary/src/controller/validate.rs @@ -23,7 +23,11 @@ use stackable_operator::{ fragment::{FromFragment, ValidationError}, merge::Merge, }, - crd::{listener::v1alpha1::Listener, s3}, + crd::{ + containerdebug::{self, ValidatedContainerdebugConfig}, + listener::v1alpha1::Listener, + s3, + }, database_connections::drivers::jdbc::{JdbcDatabaseConnection, JdbcDatabaseConnectionDetails}, k8s_openapi::api::core::v1::{ConfigMap, Secret, Volume}, kube::{Resource, ResourceExt, api::ObjectMeta}, @@ -107,6 +111,13 @@ pub enum Error { #[snafu(display("the secret lifetime of {role} role group {role_group:?} is missing"))] MissingSecretLifetime { role: DruidRole, role_group: String }, + #[snafu(display("invalid containerdebug configuration for {role} role group {role_group:?}"))] + InvalidContainerdebugConfig { + source: containerdebug::Error, + role: DruidRole, + role_group: String, + }, + #[snafu(display("failed to determine the cluster's name, namespace, or uid"))] ClusterIdentity { source: stackable_operator::v2::controller_utils::Error, @@ -149,6 +160,7 @@ pub struct ValidatedCoordinatorConfig { pub resources: Resources, pub logging: ValidatedLogging, pub affinity: StackableAffinity, + pub containerdebug: ValidatedContainerdebugConfig, pub graceful_shutdown_timeout: Duration, pub requested_secret_lifetime: Duration, } @@ -160,6 +172,7 @@ pub struct ValidatedBrokerConfig { pub resources: Resources, pub logging: ValidatedLogging, pub affinity: StackableAffinity, + pub containerdebug: ValidatedContainerdebugConfig, pub graceful_shutdown_timeout: Duration, pub requested_secret_lifetime: Duration, } @@ -171,6 +184,7 @@ pub struct ValidatedHistoricalConfig { pub resources: Resources, pub logging: ValidatedLogging, pub affinity: StackableAffinity, + pub containerdebug: ValidatedContainerdebugConfig, pub graceful_shutdown_timeout: Duration, pub requested_secret_lifetime: Duration, } @@ -182,6 +196,7 @@ pub struct ValidatedMiddleManagerConfig { pub resources: Resources, pub logging: ValidatedLogging, pub affinity: StackableAffinity, + pub containerdebug: ValidatedContainerdebugConfig, pub graceful_shutdown_timeout: Duration, pub requested_secret_lifetime: Duration, } @@ -193,6 +208,7 @@ pub struct ValidatedRouterConfig { pub resources: Resources, pub logging: ValidatedLogging, pub affinity: StackableAffinity, + pub containerdebug: ValidatedContainerdebugConfig, pub graceful_shutdown_timeout: Duration, pub requested_secret_lifetime: Duration, } @@ -626,6 +642,7 @@ fn validate_coordinator_role_group_configs( resources, logging, affinity, + containerdebug, graceful_shutdown_timeout, requested_secret_lifetime, } = merged.config; @@ -635,6 +652,12 @@ fn validate_coordinator_role_group_configs( resources, logging: validate_logging(&logging, vector_aggregator_config_map_name)?, affinity, + containerdebug: containerdebug.validate().with_context(|_| { + InvalidContainerdebugConfigSnafu { + role: druid_role.clone(), + role_group: role_group_name.to_owned(), + } + })?, graceful_shutdown_timeout: graceful_shutdown_timeout.with_context(|| { MissingGracefulShutdownTimeoutSnafu { role: druid_role.clone(), @@ -689,6 +712,7 @@ fn validate_broker_role_group_configs( resources, logging, affinity, + containerdebug, graceful_shutdown_timeout, requested_secret_lifetime, } = merged.config; @@ -698,6 +722,12 @@ fn validate_broker_role_group_configs( resources, logging: validate_logging(&logging, vector_aggregator_config_map_name)?, affinity, + containerdebug: containerdebug.validate().with_context(|_| { + InvalidContainerdebugConfigSnafu { + role: druid_role.clone(), + role_group: role_group_name.to_owned(), + } + })?, graceful_shutdown_timeout: graceful_shutdown_timeout.with_context(|| { MissingGracefulShutdownTimeoutSnafu { role: druid_role.clone(), @@ -752,6 +782,7 @@ fn validate_historical_role_group_configs( resources, logging, affinity, + containerdebug, graceful_shutdown_timeout, requested_secret_lifetime, } = merged.config; @@ -761,6 +792,12 @@ fn validate_historical_role_group_configs( resources, logging: validate_logging(&logging, vector_aggregator_config_map_name)?, affinity, + containerdebug: containerdebug.validate().with_context(|_| { + InvalidContainerdebugConfigSnafu { + role: druid_role.clone(), + role_group: role_group_name.to_owned(), + } + })?, graceful_shutdown_timeout: graceful_shutdown_timeout.with_context(|| { MissingGracefulShutdownTimeoutSnafu { role: druid_role.clone(), @@ -815,6 +852,7 @@ fn validate_middle_manager_role_group_configs( resources, logging, affinity, + containerdebug, graceful_shutdown_timeout, requested_secret_lifetime, } = merged.config; @@ -824,6 +862,12 @@ fn validate_middle_manager_role_group_configs( resources, logging: validate_logging(&logging, vector_aggregator_config_map_name)?, affinity, + containerdebug: containerdebug.validate().with_context(|_| { + InvalidContainerdebugConfigSnafu { + role: druid_role.clone(), + role_group: role_group_name.to_owned(), + } + })?, graceful_shutdown_timeout: graceful_shutdown_timeout.with_context(|| { MissingGracefulShutdownTimeoutSnafu { role: druid_role.clone(), @@ -878,6 +922,7 @@ fn validate_router_role_group_configs( resources, logging, affinity, + containerdebug, graceful_shutdown_timeout, requested_secret_lifetime, } = merged.config; @@ -887,6 +932,12 @@ fn validate_router_role_group_configs( resources, logging: validate_logging(&logging, vector_aggregator_config_map_name)?, affinity, + containerdebug: containerdebug.validate().with_context(|_| { + InvalidContainerdebugConfigSnafu { + role: druid_role.clone(), + role_group: role_group_name.to_owned(), + } + })?, graceful_shutdown_timeout: graceful_shutdown_timeout.with_context(|| { MissingGracefulShutdownTimeoutSnafu { role: druid_role.clone(), @@ -1178,4 +1229,116 @@ mod tests { "expected a ClusterIdentity error when the cluster has no uid" ); } + + /// `MINIMAL_DRUID_YAML` with the given lines added to the `config` of every role. + fn minimal_druid_yaml_with_role_config(role_config: &str) -> String { + let mut yaml = MINIMAL_DRUID_YAML.to_owned(); + for role in [ + "brokers", + "coordinators", + "historicals", + "middleManagers", + "routers", + ] { + let role_line = format!(" {role}:\n roleGroups:"); + assert_eq!( + yaml.matches(&role_line).count(), + 1, + "{role} is in the fixture" + ); + yaml = yaml.replace( + &role_line, + &format!(" {role}:\n config:\n{role_config} roleGroups:"), + ); + } + yaml + } + + /// A role `config` that does not mention `containerdebug` still gets the default, so the + /// `containerdebug` field of the CRD must be optional in every role. + #[test] + fn containerdebug_defaults_when_not_configured() { + use stackable_operator::crd::containerdebug::{ + DEFAULT_INTERVAL, ValidatedContainerdebugConfig, + }; + + let druid = druid_from_yaml(&minimal_druid_yaml_with_role_config( + " gracefulShutdownTimeout: 1m\n", + )); + let cluster = match validate(&druid, &dereferenced_objects(), &operator_environment()) { + Ok(cluster) => cluster, + Err(error) => panic!("the cluster is valid, but: {error:?}"), + }; + let default_group = RoleGroupName::from_str("default").expect("valid role group name"); + let default = ValidatedContainerdebugConfig::Enabled { + interval: DEFAULT_INTERVAL, + }; + + assert_eq!( + cluster.coordinator_role_group_configs[&default_group] + .config + .containerdebug, + default + ); + assert_eq!( + cluster.broker_role_group_configs[&default_group] + .config + .containerdebug, + default + ); + assert_eq!( + cluster.historical_role_group_configs[&default_group] + .config + .containerdebug, + default + ); + assert_eq!( + cluster.middle_manager_role_group_configs[&default_group] + .config + .containerdebug, + default + ); + assert_eq!( + cluster.router_role_group_configs[&default_group] + .config + .containerdebug, + default + ); + } + + /// An invalid `containerdebug` config fails the validation, naming the role and the role + /// group. + #[test] + fn zero_containerdebug_interval_fails_validation() { + let yaml = MINIMAL_DRUID_YAML.replace( + " historicals:\n roleGroups:", + " historicals:\n config:\n containerdebug:\n interval: 0s\n roleGroups:", + ); + assert_ne!( + yaml, MINIMAL_DRUID_YAML, + "the historicals are in the fixture" + ); + + let Err(error) = validate( + &druid_from_yaml(&yaml), + &dereferenced_objects(), + &operator_environment(), + ) else { + panic!("a zero containerdebug interval must fail the validation"); + }; + let chain: Vec = + 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 historical role group \"default\"", + "the containerdebug interval must not be zero", + ] + ); + } } diff --git a/rust/operator-binary/src/crd/mod.rs b/rust/operator-binary/src/crd/mod.rs index 1e49e15c..88dda945 100644 --- a/rust/operator-binary/src/crd/mod.rs +++ b/rust/operator-binary/src/crd/mod.rs @@ -14,6 +14,10 @@ use stackable_operator::{ constant, crd::{ authentication::{core, oidc}, + containerdebug::{ + ValidatedContainerdebugConfig, default_containerdebug_config, + v1alpha1::ContainerdebugConfig, + }, s3, }, deep_merger::ObjectOverrides, @@ -487,20 +491,26 @@ impl DruidRole { commands } - pub fn main_container_start_command(&self) -> String { + pub fn main_container_start_command( + &self, + containerdebug: &ValidatedContainerdebugConfig, + ) -> String { // We need to store the druid process PID for the graceful shutdown lifecycle pre stop hook. formatdoc! {" {COMMON_BASH_TRAP_FUNCTIONS} {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} /stackable/druid/bin/run-druid {process_name} {RW_CONFIG_DIRECTORY} & echo \"$!\" >> /tmp/DRUID_PID wait_for_termination $(cat /tmp/DRUID_PID) {create_vector_shutdown_file_command} ", process_name = self.get_process_name(), + containerdebug_command = containerdebug + .background_command(STACKABLE_LOG_DIR) + .unwrap_or_default(), file_log_directory = FILE_LOG_DIRECTORY.as_ref(), remove_vector_shutdown_file_command = remove_vector_shutdown_file_command(STACKABLE_LOG_DIR), @@ -563,7 +573,7 @@ pub struct IngestionSpec { /// passed explicitly because `macro_rules!` cannot synthesize identifiers. macro_rules! role_group_config { ($name:ident, $fragment:ident, $storage:ty, $resources:expr, $secret_lifetime:expr $(,)?) => { - #[derive(Clone, Debug, Default, Fragment, JsonSchema, PartialEq)] + #[derive(Clone, Debug, Fragment, JsonSchema, PartialEq)] #[fragment_attrs( derive( Clone, @@ -584,6 +594,8 @@ macro_rules! role_group_config { pub logging: Logging, #[fragment_attrs(serde(default))] pub affinity: StackableAffinity, + #[fragment_attrs(serde(default))] + pub containerdebug: ContainerdebugConfig, /// The time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. /// Read more about graceful shutdown in the /// [graceful shutdown documentation](DOCS_BASE_URL_PLACEHOLDER/druid/usage-guide/operations/graceful-shutdown). @@ -606,6 +618,7 @@ macro_rules! role_group_config { resources: $resources.to_owned(), logging: product_logging::spec::default_logging(), affinity: get_affinity(cluster_name, role, deep_storage), + containerdebug: default_containerdebug_config(), graceful_shutdown_timeout: Some(role.default_graceful_shutdown_timeout()), requested_secret_lifetime: Some($secret_lifetime), }