Skip to content

Commit fcf4c3e

Browse files
feat: Collect the containerdebug logs (#832)
* feat: Collect the containerdebug logs * chore: Update changelog * chore: Improve code style * chore: Upgrade serde-saphyr * chore: Inline CONTAINERDEBUG_LOG_DIR * test(smoke): Fix test assertion * chore: Revert downgrade of base64
1 parent b3e8fd8 commit fcf4c3e

16 files changed

Lines changed: 786 additions & 37 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- Add `/ready` endpoint to the operator Deployment, which reports the CRD installation status ([#812]).
1010
- Add support for 2.6.7 and 3.0.0 (experimental) ([#815]).
1111
- Masters and region servers now have a default affinity to the OPA Pods when OPA authorization is configured ([#816]).
12+
- The logs of the `containerdebug` process are now collected by the Vector agent and forwarded to
13+
the Vector aggregator ([#832]).
1214

1315
### Changed
1416

@@ -56,6 +58,10 @@
5658
- BREAKING: The rest-server listener PVC template now carries the recommended labels without the
5759
version label, so that the labels stay stable across upgrades.
5860
Existing rest-server StatefulSets must be deleted once before the new operator can reconcile them ([#799]).
61+
- The `containerdebug` process writes its log file again. The operator set
62+
`CONTAINERDEBUG_LOG_DIRECTORY`, which containerdebug stopped reading in its version 0.2.0 when it
63+
moved to `stackable-telemetry`; the directory is now set via `FILE_LOG_DIRECTORY`. The file is
64+
rotated hourly and at most two files are kept, because rotation is opt-in ([#832]).
5965

6066
[#776]: https://github.com/stackabletech/hbase-operator/pull/776
6167
[#782]: https://github.com/stackabletech/hbase-operator/pull/782
@@ -76,6 +82,7 @@
7682
[#825]: https://github.com/stackabletech/hbase-operator/pull/825
7783
[#827]: https://github.com/stackabletech/hbase-operator/pull/827
7884
[#829]: https://github.com/stackabletech/hbase-operator/pull/829
85+
[#832]: https://github.com/stackabletech/hbase-operator/pull/832
7986

8087
## [26.7.0] - 2026-07-21
8188

‎Cargo.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.nix‎

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/modules/hbase/pages/usage-guide/logging.adoc‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@ spec:
2222
enableVectorAgent: true
2323
----
2424

25+
NOTE: The logs of the xref:concepts:observability/containerdebug.adoc[`containerdebug` process] are collected as well.
26+
They are labelled `container: containerdebug`, although no such Kubernetes container exists.
27+
The process runs in the background of the `hbase` container.
28+
The label comes from `/stackable/log/containerdebug`, the directory which the operator sets with the `FILE_LOG_DIRECTORY` environment variable and from which the Vector agent derives the container name.
29+
Overriding `FILE_LOG_DIRECTORY` with `envOverrides` therefore changes how these logs are aggregated.
30+
The agent only collects files one level below `/stackable/log`, so a sibling directory such as `/stackable/log/hbase` relabels the events instead of dropping them, while any deeper or shallower path stops the aggregation.
31+
A path outside `/stackable/log` also leaves the size-capped log volume.
32+
2533
Further information on how to configure logging, can be found in xref:concepts:logging.adoc[].

‎rust/operator-binary/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ built.workspace = true
3131

3232
[dev-dependencies]
3333
rstest.workspace = true
34+
stackable-operator = { workspace = true, features = ["test-support"] }
3435
yaml_serde.workspace = true

‎rust/operator-binary/src/controller/build/container.rs‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
use std::str::FromStr;
99

10+
use const_format::concatcp;
1011
use indoc::formatdoc;
1112
use snafu::{ResultExt, Snafu};
1213
use stackable_operator::{
@@ -56,7 +57,9 @@ constant!(HADOOP_CONF_DIR_ENV: EnvVarName = "HADOOP_CONF_DIR");
5657
constant!(pub(crate) REGION_MOVER_OPTS_ENV: EnvVarName = "REGION_MOVER_OPTS");
5758
constant!(pub(crate) RUN_REGION_MOVER_ENV: EnvVarName = "RUN_REGION_MOVER");
5859
constant!(STACKABLE_LOG_DIR_ENV: EnvVarName = "STACKABLE_LOG_DIR");
59-
constant!(CONTAINERDEBUG_LOG_DIRECTORY_ENV: EnvVarName = "CONTAINERDEBUG_LOG_DIRECTORY");
60+
constant!(FILE_LOG_DIRECTORY_ENV: EnvVarName = "FILE_LOG_DIRECTORY");
61+
constant!(FILE_LOG_MAX_FILES_ENV: EnvVarName = "FILE_LOG_MAX_FILES");
62+
constant!(FILE_LOG_ROTATION_PERIOD_ENV: EnvVarName = "FILE_LOG_ROTATION_PERIOD");
6063

6164
// These constants are hard coded in hbase-entrypoint.sh
6265
// You need to change them there too.
@@ -145,11 +148,18 @@ pub(crate) fn containers_and_volumes(inputs: &RoleGroupInputs) -> Result<Contain
145148
.with_value(&REGION_MOVER_OPTS_ENV, inputs.region_mover_opts.clone())
146149
.with_value(&RUN_REGION_MOVER_ENV, inputs.run_region_mover.to_string())
147150
.with_value(&STACKABLE_LOG_DIR_ENV, STACKABLE_LOG_DIR)
148-
// Needed for the `containerdebug` process to log its tracing information to.
151+
// Let the `containerdebug` process write its tracing information to a file. These are the
152+
// generic `stackable-telemetry` variables and apply to the whole HBase container, so any
153+
// other telemetry-based process in it would log into the same directory. It must be
154+
// exactly one level below the log directory, because the Vector agent derives the
155+
// container name from that path segment.
149156
.with_value(
150-
&CONTAINERDEBUG_LOG_DIRECTORY_ENV,
151-
format!("{STACKABLE_LOG_DIR}/containerdebug"),
157+
&FILE_LOG_DIRECTORY_ENV,
158+
concatcp!(STACKABLE_LOG_DIR, "/containerdebug"),
152159
)
160+
// Rotation is opt-in, so without these the file would grow unbounded.
161+
.with_value(&FILE_LOG_ROTATION_PERIOD_ENV, "hourly")
162+
.with_value(&FILE_LOG_MAX_FILES_ENV, "2")
153163
// Empty when Kerberos is disabled.
154164
.merge(kerberos::kerberos_env_vars(cluster))
155165
// apply overrides last of all; `EnvVarSet` is keyed by name, so iteration is already
@@ -217,6 +227,9 @@ pub(crate) fn containers_and_volumes(inputs: &RoleGroupInputs) -> Result<Contain
217227
VolumeBuilder::new(&*LOG_VOLUME_NAME)
218228
.with_empty_dir(
219229
None::<String>,
230+
// Only the HBase log files are budgeted. The `containerdebug` files in this
231+
// volume are rotated by time, not by size, so they have no budget; raising
232+
// `FILE_LOG_LEVEL` via `envOverrides` can therefore evict the Pod.
220233
Some(product_logging::framework::calculate_log_volume_size_limit(
221234
&[MAX_HBASE_LOG_FILES_SIZE],
222235
)),
@@ -303,6 +316,8 @@ mod tests {
303316
let _ = *REGION_MOVER_OPTS_ENV;
304317
let _ = *RUN_REGION_MOVER_ENV;
305318
let _ = *STACKABLE_LOG_DIR_ENV;
306-
let _ = *CONTAINERDEBUG_LOG_DIRECTORY_ENV;
319+
let _ = *FILE_LOG_DIRECTORY_ENV;
320+
let _ = *FILE_LOG_MAX_FILES_ENV;
321+
let _ = *FILE_LOG_ROTATION_PERIOD_ENV;
307322
}
308323
}

‎rust/operator-binary/src/controller/build/properties/hbase_env.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ mod tests {
112112
false,
113113
"-Xtest".to_string(),
114114
BTreeMap::from([(
115-
EnvVarName::from_str("CUSTOM_VAR").expect("valid variable name"),
115+
EnvVarName::from_str_unsafe("CUSTOM_VAR"),
116116
"custom_value".to_string(),
117117
)]),
118118
)

‎rust/operator-binary/src/controller/build/properties/product_logging/mod.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ mod tests {
6161
assert!(!content.is_empty());
6262
// A kept source must be present ...
6363
assert!(content.contains("files_log4j2"));
64+
assert!(content.contains("files_tracing_rs"));
65+
assert!(content.contains("*.tracing-rs.json"));
6466
// ... while a product-specific source we don't emit must not.
65-
assert!(!content.contains("files_tracing_rs"));
67+
assert!(!content.contains("files_py"));
6668
}
6769
}

0 commit comments

Comments
 (0)