Skip to content

Commit 2eb61e9

Browse files
Techassilfranckenightkrrazvansbernauer
authored
chore: Import containerdebug (#1233)
* Initial commit * Add example * Update dependencies and log user executing the current program * Add loop mode Fixes #7 * Fix clippy warnings * Rename --loop-interval to --loop * Log on run start/end Fixes #4 * Add file output option Fixes #5 * Split SystemInformation into modules, add logging Fixes #6 * Switch to operator-rs' logging * Remove duration brackets * Add CI and github config (#12) * Add CI and github config Mostly copied from operator-rs. Would be nice to have this managed by operator-templating, but that depends on stackabletech/operator-templating#80. * Import pre-commit and cargo deny config as well * pre-commit * Update cargo-deny to v2.0.4 * Update dependencies * Update deny.toml from op-rs * Update .github/workflows/build.yml Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com> --------- Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com> * Drop unmaintained users dependency (#13) * Add CI and github config Mostly copied from operator-rs. Would be nice to have this managed by operator-templating, but that depends on stackabletech/operator-templating#80. * Import pre-commit and cargo deny config as well * pre-commit * Drop unmaintained users dependency It's unmaintained, has open vulnerabilities, and is redundant with sysinfo which we already use. * Update cargo-deny to v2.0.4 * Update dependencies * Update deny.toml from op-rs * Release v0.1.0 (#14) * Wrap all output in a containerdebug span (#18) * Wrap all output in a containerdebug span * Changelog * Downgrade DNS errors to warnings (#17) * Downgrade DNS errors to warnings * Changelog * Cache sysinfo data, and only query for the data we actually use (#20) * Cache sysinfo data, and only query for the data we actually use * Changelog * Release v0.1.1 (#22) * Increase default interval from minutely to half-hourly (#23) * Increase default interval from minutely to half-hourly * Changelog * Update documentation a bit (#24) * Update documentation a bit * Formatting * Linebreaks * Reformat example output as code block * chore: Bump sysinfo to 0.33; cargo update (#27) * cargo update * Bump sysinfo 0.32 -> 0.33 * Various updates (#45) * Various updates - Dependency updates - Log open files limit - Reduce logging at info slightly - Add rust-toolchain.toml - Fix pre-commit warnings * Various updates - Dep updates - Rust toolchain update - PR template update * rustfmt * Update dependencies * Update operator-rs * Update dependencies * better telemetry integration * rustfmt * rustfmt * use our version of cargo-udeps * pre-commit * pre-commit * add markdownlint config * add markdownlint & yamllint config * md lint * address review comment * fix: Replace long running span with short lived spans (#46) * fix: Replace long running span with short lived spans * chore: replace print_startup_string with print_startup_string Note: this has the added benefit of displaying the correct tracing target (or call-site), instead of displaying stackable_operator * chore: Update changelog * Release v0.2.0 (#47) * chore: Bump Rust dependencies and Rust version (#52) * chore: Bump Rust dependencies and Rust version * bump Rust * Bump cargo-deny * Use op-rs 0.107.0 * changelog * chore: Release 0.3.0 (#53) * fix: Code review bug fixes and cleanup (#55) * fix: Log GID instead of UID in user GID tracing field The tracing statement for `user.gid` was reading from `user.uid` instead of `user.gid`, causing the wrong value to be reported. * refactor: Use idiomatic empty check for disk collection Replace `into_iter().next().is_none()` with `list().is_empty()` for clarity, and use `list().iter()` for the actual collection. * fix: Remove stale .source() call with unused result This was likely a debugging leftover — the error source chain is already captured via the `successors` iterator below. * fix: Fix typo "proess" -> "process" in error message * fix: Replace unwrap() calls with error logging in collection loop JSON serialization and file write can fail at runtime (e.g. disk full). Log the error and continue the loop instead of crashing, since this tool may run continuously for hours. * fix: Use tokio::time::sleep instead of std::thread::sleep std::thread::sleep blocks the entire tokio worker thread. Since main is already async, use the non-blocking alternative. * fix: Handle DNS resolver initialization failure gracefully In a container debugging tool, broken DNS config (/etc/resolv.conf) is a likely scenario to diagnose. Log the error and skip DNS lookups instead of panicking. * fix: Wrap network collector in ComponentResult for consistent error handling The network collector silently swallowed interface listing errors by returning empty data. Now it returns Result so the orchestrator wraps it in ComponentResult, matching the pattern used by other fallible collectors. Errors appear in JSON output instead of being silently lost. * refactor: Use BTreeMap for deterministic JSON key ordering HashMap produces non-deterministic JSON output, making it hard to diff containerdebug output across runs. BTreeMap sorts keys consistently. * fix: Bump rustls-webpki to 0.103.10 to negate RUSTSEC-2026-0049 * chore: Remove undetected, ignored advisories --------- Co-authored-by: Techassi <git@techassi.dev> * fix: Don't log ANSI escape sequences if stdout is a file (#59) * fix: Don't log ANSI escape sequences if stdout is a file * chore: Add changelog entry * feat: Report open file descriptor count (#58) Read /proc/self/fd to report the actual number of open file descriptors alongside the existing limit. Comparing usage vs limit helps diagnose "too many open files" errors. * feat: Add disk usage percentage and warn on high usage (#57) * fix: Log GID instead of UID in user GID tracing field The tracing statement for `user.gid` was reading from `user.uid` instead of `user.gid`, causing the wrong value to be reported. * refactor: Use idiomatic empty check for disk collection Replace `into_iter().next().is_none()` with `list().is_empty()` for clarity, and use `list().iter()` for the actual collection. * fix: Remove stale .source() call with unused result This was likely a debugging leftover — the error source chain is already captured via the `successors` iterator below. * fix: Fix typo "proess" -> "process" in error message * fix: Replace unwrap() calls with error logging in collection loop JSON serialization and file write can fail at runtime (e.g. disk full). Log the error and continue the loop instead of crashing, since this tool may run continuously for hours. * fix: Use tokio::time::sleep instead of std::thread::sleep std::thread::sleep blocks the entire tokio worker thread. Since main is already async, use the non-blocking alternative. * fix: Handle DNS resolver initialization failure gracefully In a container debugging tool, broken DNS config (/etc/resolv.conf) is a likely scenario to diagnose. Log the error and skip DNS lookups instead of panicking. * fix: Wrap network collector in ComponentResult for consistent error handling The network collector silently swallowed interface listing errors by returning empty data. Now it returns Result so the orchestrator wraps it in ComponentResult, matching the pattern used by other fallible collectors. Errors appear in JSON output instead of being silently lost. * refactor: Use BTreeMap for deterministic JSON key ordering HashMap produces non-deterministic JSON output, making it hard to diff containerdebug output across runs. BTreeMap sorts keys consistently. * feat: Add disk usage percentage and warn on high usage Add `usage_percent` field to disk collection output. When a disk exceeds 85% usage, log at WARN level instead of INFO so it stands out in log aggregation systems. * Apply review suggestion * Update dependencies (#60) * chore: Dependecy bumps (#63) * chore: Dependecy bumps * Bump to 0.4.0 * Use new op-rs tags * chore: Finalize import * chore: Fix clippy lints * chore(containerdebug): Add rustfmt changes --------- Co-authored-by: Lars Francke <git@lars-francke.de> Co-authored-by: Natalie Klestrup Röijezon <nat@nullable.se> Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com> Co-authored-by: Sebastian Bernauer <sebastian.bernauer@stackable.tech> Co-authored-by: Lars Francke <lars.francke@stackable.tech> Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
1 parent 39511c7 commit 2eb61e9

19 files changed

Lines changed: 1980 additions & 18 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ arc-swap = "1.7.0"
1515
async-trait = "0.1.89"
1616
axum = { version = "0.8.1", features = ["http2"] }
1717
base64 = "0.22"
18+
built = "0.8.1"
1819
clap = { version = "4.5.17", features = ["derive", "cargo", "env"] }
1920
const_format = "0.2.33"
2021
# Pinned to the old RustCrypto generation: const-oid 0.10 requires x509-cert 0.3,
@@ -31,6 +32,7 @@ educe = { version = "0.6.0", default-features = false, features = ["Clone", "Deb
3132
either = "1.13.0"
3233
futures = "0.3.30"
3334
futures-util = "0.3.30"
35+
hickory-resolver = "0.26.1"
3436
http = "1.3.1"
3537
humantime = "2.1.0"
3638
indexmap = "2.5.0"
@@ -46,6 +48,7 @@ k8s-openapi = { version = "0.28.0", default-features = false, features = ["schem
4648
# We use rustls instead of openssl for easier portability, e.g. so that we can build stackablectl without the need to vendor (build from source) openssl
4749
# We use ring instead of aws-lc-rs, as this currently fails to build in "make run-dev"
4850
kube = { version = "4.0.0", default-features = false, features = ["client", "jsonpatch", "runtime", "derive", "admission", "rustls-tls", "ring"] }
51+
local-ip-address = "0.6.13"
4952
opentelemetry = "0.32.0"
5053
opentelemetry_sdk = { version = "0.32.0", features = ["rt-tokio"] }
5154
opentelemetry-appender-tracing = "0.32.0"
@@ -81,6 +84,7 @@ snafu = "0.9.1"
8184
stackable-operator-derive = { path = "stackable-operator-derive" }
8285
strum = { version = "0.28.0", features = ["derive"] }
8386
syn = "2.0.118"
87+
sysinfo = "0.39.5"
8488
tempfile = "3.12.0"
8589
time = { version = "0.3.49" }
8690
tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread", "fs"] }

crates/containerdebug/CHANGELOG.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [Unreleased]
6+
7+
## [0.4.0] - 2026-05-19
8+
9+
### Changed
10+
11+
- Bump `hickory-resolver` to 0.26, `sysinfo` to 0.39 and Rust to 1.95.0 ([#63]).
12+
13+
[#63]: https://github.com/stackabletech/containerdebug/pull/63
14+
15+
### Fixed
16+
17+
- Don't log ANSI escape sequences if stdout is a file ([#59]).
18+
19+
[#59]: https://github.com/stackabletech/containerdebug/pull/59
20+
21+
## [0.3.0] - 2026-03-10
22+
23+
### Changed
24+
25+
- Dependency bumps. This includes switching to async code (using `tokio`), as `hickory-resolver` 0.25 removed the synchronous APIs ([#52]).
26+
27+
[#52]: https://github.com/stackabletech/containerdebug/pull/52
28+
29+
## [0.2.0] - 2025-05-26
30+
31+
### Changed
32+
33+
- Increased the default `--loop` interval from every minute to every 30 minutes ([#23]).
34+
- Collect and output the open files limit ([#45]).
35+
36+
### Fixes
37+
38+
- Move the span inside the loop ([#46]).
39+
40+
[#23]: https://github.com/stackabletech/containerdebug/pull/23
41+
[#45]: https://github.com/stackabletech/containerdebug/pull/45
42+
[#46]: https://github.com/stackabletech/containerdebug/pull/46
43+
44+
## [0.1.1] - 2024-12-16
45+
46+
### Changed
47+
48+
- Downgraded DNS errors to warnings ([#17]).
49+
- All output is now wrapped in a "containerdebug" span ([#18]).
50+
51+
### Fixes
52+
53+
- Reduced memory usage dramatically by limiting and caching fetched information ([#20]).
54+
55+
[#17]: https://github.com/stackabletech/containerdebug/pull/17
56+
[#18]: https://github.com/stackabletech/containerdebug/pull/18
57+
[#20]: https://github.com/stackabletech/containerdebug/pull/20
58+
59+
## [0.1.0] - 2024-12-09
60+
61+
### Added
62+
63+
- Initial release.

crates/containerdebug/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "containerdebug"
3+
version = "0.4.0"
4+
edition.workspace = true
5+
6+
[dependencies]
7+
clap.workspace = true
8+
hickory-resolver.workspace = true
9+
local-ip-address.workspace = true
10+
serde.workspace = true
11+
serde_json.workspace = true
12+
snafu.workspace = true
13+
sysinfo = { workspace = true, features = ["serde"] }
14+
tokio.workspace = true
15+
tracing.workspace = true
16+
17+
stackable-shared = { path = "../stackable-shared", default-features = false }
18+
stackable-telemetry = { path = "../stackable-telemetry", default-features = false, features = ["clap"] }
19+
20+
[build-dependencies]
21+
built = { workspace = true, features = ["chrono", "git2"] }

crates/containerdebug/LICENSE

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
5+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6+
7+
1. Definitions.
8+
9+
"License" shall mean the terms and conditions for use, reproduction,
10+
and distribution as defined by Sections 1 through 9 of this document.
11+
12+
"Licensor" shall mean the copyright owner or entity authorized by
13+
the copyright owner that is granting the License.
14+
15+
"Legal Entity" shall mean the union of the acting entity and all
16+
other entities that control, are controlled by, or are under common
17+
control with that entity. For the purposes of this definition,
18+
"control" means (i) the power, direct or indirect, to cause the
19+
direction or management of such entity, whether by contract or
20+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
21+
outstanding shares, or (iii) beneficial ownership of such entity.
22+
23+
"You" (or "Your") shall mean an individual or Legal Entity
24+
exercising permissions granted by this License.
25+
26+
"Source" form shall mean the preferred form for making modifications,
27+
including but not limited to software source code, documentation
28+
source, and configuration files.
29+
30+
"Object" form shall mean any form resulting from mechanical
31+
transformation or translation of a Source form, including but
32+
not limited to compiled object code, generated documentation,
33+
and conversions to other media types.
34+
35+
"Work" shall mean the work of authorship, whether in Source or
36+
Object form, made available under the License, as indicated by a
37+
copyright notice that is included in or attached to the work
38+
(an example is provided in the Appendix below).
39+
40+
"Derivative Works" shall mean any work, whether in Source or Object
41+
form, that is based on (or derived from) the Work and for which the
42+
editorial revisions, annotations, elaborations, or other modifications
43+
represent, as a whole, an original work of authorship. For the purposes
44+
of this License, Derivative Works shall not include works that remain
45+
separable from, or merely link (or bind by name) to the interfaces of,
46+
the Work and Derivative Works thereof.
47+
48+
"Contribution" shall mean any work of authorship, including
49+
the original version of the Work and any modifications or additions
50+
to that Work or Derivative Works thereof, that is intentionally
51+
submitted to Licensor for inclusion in the Work by the copyright owner
52+
or by an individual or Legal Entity authorized to submit on behalf of
53+
the copyright owner. For the purposes of this definition, "submitted"
54+
means any form of electronic, verbal, or written communication sent
55+
to the Licensor or its representatives, including but not limited to
56+
communication on electronic mailing lists, source code control systems,
57+
and issue tracking systems that are managed by, or on behalf of, the
58+
Licensor for the purpose of discussing and improving the Work, but
59+
excluding communication that is conspicuously marked or otherwise
60+
designated in writing by the copyright owner as "Not a Contribution."
61+
62+
"Contributor" shall mean Licensor and any individual or Legal Entity
63+
on behalf of whom a Contribution has been received by Licensor and
64+
subsequently incorporated within the Work.
65+
66+
2. Grant of Copyright License. Subject to the terms and conditions of
67+
this License, each Contributor hereby grants to You a perpetual,
68+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69+
copyright license to reproduce, prepare Derivative Works of,
70+
publicly display, publicly perform, sublicense, and distribute the
71+
Work and such Derivative Works in Source or Object form.
72+
73+
3. Grant of Patent License. Subject to the terms and conditions of
74+
this License, each Contributor hereby grants to You a perpetual,
75+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76+
(except as stated in this section) patent license to make, have made,
77+
use, offer to sell, sell, import, and otherwise transfer the Work,
78+
where such license applies only to those patent claims licensable
79+
by such Contributor that are necessarily infringed by their
80+
Contribution(s) alone or by combination of their Contribution(s)
81+
with the Work to which such Contribution(s) was submitted. If You
82+
institute patent litigation against any entity (including a
83+
cross-claim or counterclaim in a lawsuit) alleging that the Work
84+
or a Contribution incorporated within the Work constitutes direct
85+
or contributory patent infringement, then any patent licenses
86+
granted to You under this License for that Work shall terminate
87+
as of the date such litigation is filed.
88+
89+
4. Redistribution. You may reproduce and distribute copies of the
90+
Work or Derivative Works thereof in any medium, with or without
91+
modifications, and in Source or Object form, provided that You
92+
meet the following conditions:
93+
94+
(a) You must give any other recipients of the Work or
95+
Derivative Works a copy of this License; and
96+
97+
(b) You must cause any modified files to carry prominent notices
98+
stating that You changed the files; and
99+
100+
(c) You must retain, in the Source form of any Derivative Works
101+
that You distribute, all copyright, patent, trademark, and
102+
attribution notices from the Source form of the Work,
103+
excluding those notices that do not pertain to any part of
104+
the Derivative Works; and
105+
106+
(d) If the Work includes a "NOTICE" text file as part of its
107+
distribution, then any Derivative Works that You distribute must
108+
include a readable copy of the attribution notices contained
109+
within such NOTICE file, excluding those notices that do not
110+
pertain to any part of the Derivative Works, in at least one
111+
of the following places: within a NOTICE text file distributed
112+
as part of the Derivative Works; within the Source form or
113+
documentation, if provided along with the Derivative Works; or,
114+
within a display generated by the Derivative Works, if and
115+
wherever such third-party notices normally appear. The contents
116+
of the NOTICE file are for informational purposes only and
117+
do not modify the License. You may add Your own attribution
118+
notices within Derivative Works that You distribute, alongside
119+
or as an addendum to the NOTICE text from the Work, provided
120+
that such additional attribution notices cannot be construed
121+
as modifying the License.
122+
123+
You may add Your own copyright statement to Your modifications and
124+
may provide additional or different license terms and conditions
125+
for use, reproduction, or distribution of Your modifications, or
126+
for any such Derivative Works as a whole, provided Your use,
127+
reproduction, and distribution of the Work otherwise complies with
128+
the conditions stated in this License.
129+
130+
5. Submission of Contributions. Unless You explicitly state otherwise,
131+
any Contribution intentionally submitted for inclusion in the Work
132+
by You to the Licensor shall be under the terms and conditions of
133+
this License, without any additional terms or conditions.
134+
Notwithstanding the above, nothing herein shall supersede or modify
135+
the terms of any separate license agreement you may have executed
136+
with Licensor regarding such Contributions.
137+
138+
6. Trademarks. This License does not grant permission to use the trade
139+
names, trademarks, service marks, or product names of the Licensor,
140+
except as required for reasonable and customary use in describing the
141+
origin of the Work and reproducing the content of the NOTICE file.
142+
143+
7. Disclaimer of Warranty. Unless required by applicable law or
144+
agreed to in writing, Licensor provides the Work (and each
145+
Contributor provides its Contributions) on an "AS IS" BASIS,
146+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147+
implied, including, without limitation, any warranties or conditions
148+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149+
PARTICULAR PURPOSE. You are solely responsible for determining the
150+
appropriateness of using or redistributing the Work and assume any
151+
risks associated with Your exercise of permissions under this License.
152+
153+
8. Limitation of Liability. In no event and under no legal theory,
154+
whether in tort (including negligence), contract, or otherwise,
155+
unless required by applicable law (such as deliberate and grossly
156+
negligent acts) or agreed to in writing, shall any Contributor be
157+
liable to You for damages, including any direct, indirect, special,
158+
incidental, or consequential damages of any character arising as a
159+
result of this License or out of the use or inability to use the
160+
Work (including but not limited to damages for loss of goodwill,
161+
work stoppage, computer failure or malfunction, or any and all
162+
other commercial damages or losses), even if such Contributor
163+
has been advised of the possibility of such damages.
164+
165+
9. Accepting Warranty or Additional Liability. While redistributing
166+
the Work or Derivative Works thereof, You may choose to offer,
167+
and charge a fee for, acceptance of support, warranty, indemnity,
168+
or other liability obligations and/or rights consistent with this
169+
License. However, in accepting such obligations, You may act only
170+
on Your own behalf and on Your sole responsibility, not on behalf
171+
of any other Contributor, and only if You agree to indemnify,
172+
defend, and hold each Contributor harmless for any liability
173+
incurred by, or claims asserted against, such Contributor by reason
174+
of your accepting any such warranty or additional liability.
175+
176+
END OF TERMS AND CONDITIONS
177+
178+
APPENDIX: How to apply the Apache License to your work.
179+
180+
To apply the Apache License to your work, attach the following
181+
boilerplate notice, with the fields enclosed by brackets "[]"
182+
replaced with your own identifying information. (Don't include
183+
the brackets!) The text should be enclosed in the appropriate
184+
comment syntax for the file format. We also recommend that a
185+
file or class name and description of purpose be included on the
186+
same "printed page" as the copyright notice for easier
187+
identification within third-party archives.
188+
189+
Copyright [yyyy] [name of copyright owner]
190+
191+
Licensed under the Apache License, Version 2.0 (the "License");
192+
you may not use this file except in compliance with the License.
193+
You may obtain a copy of the License at
194+
195+
http://www.apache.org/licenses/LICENSE-2.0
196+
197+
Unless required by applicable law or agreed to in writing, software
198+
distributed under the License is distributed on an "AS IS" BASIS,
199+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200+
See the License for the specific language governing permissions and
201+
limitations under the License.

0 commit comments

Comments
 (0)