Skip to content

Commit c6eacbb

Browse files
sbernauerTechassi
authored andcommitted
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
1 parent ea7f66a commit c6eacbb

5 files changed

Lines changed: 60 additions & 29 deletions

File tree

crates/containerdebug/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Changed
8+
9+
- Dependency bumps. This includes switching to async code (using `tokio`), as `hickory-resolver` 0.25 removed the synchronous APIs ([#52]).
10+
11+
[#52]: https://github.com/stackabletech/containerdebug/pull/52
12+
713
## [0.2.0] - 2025-05-26
814

915
### Changed

crates/containerdebug/Cargo.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ edition = "2024"
55

66
[dependencies]
77
clap = { version = "4.5", features = ["derive"] }
8-
9-
hickory-resolver = "0.24"
8+
hickory-resolver = "0.25"
109
local-ip-address = "0.6"
1110
serde = { version = "1.0", features = ["derive"] }
1211
serde_json = "1.0"
13-
snafu = "0.8"
14-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs", tag = "stackable-operator-0.93.1", features = ["telemetry"] }
15-
sysinfo = { version = "0.35", features = ["serde"] }
12+
snafu = "0.9"
13+
sysinfo = { version = "0.38", features = ["serde"] }
14+
tokio = { version = "1.49", default-features = false, features = ["rt-multi-thread", "macros"] }
1615
tracing = "0.1"
1716

17+
stackable-shared = {git = "https://github.com/stackabletech/operator-rs", tag = "stackable-operator-0.107.0", default-features = false }
18+
stackable-telemetry = {git = "https://github.com/stackabletech/operator-rs", tag = "stackable-operator-0.107.0", default-features = false, features = ["clap"] }
19+
1820
[build-dependencies]
1921
built = { version = "0.8", features = ["chrono", "git2"] }

crates/containerdebug/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ mod error;
22
mod system_information;
33

44
use clap::Parser;
5-
use stackable_operator::telemetry::Tracing;
5+
use stackable_telemetry::{Tracing, tracing::TelemetryOptions};
66
use std::path::PathBuf;
77

88
use crate::system_information::SystemInformation;
9-
use stackable_operator::telemetry::tracing::TelemetryOptions;
109
use std::time::Instant;
1110

1211
const APP_NAME: &str = "containerdebug";
@@ -22,7 +21,7 @@ struct Opts {
2221
num_args = 0..=1,
2322
require_equals = true,
2423
)]
25-
loop_interval: Option<stackable_operator::time::Duration>,
24+
loop_interval: Option<stackable_shared::time::Duration>,
2625

2726
/// Write collected information to OUTPUT as JSON
2827
#[clap(long, short = 'o')]
@@ -36,7 +35,8 @@ mod built_info {
3635
include!(concat!(env!("OUT_DIR"), "/built.rs"));
3736
}
3837

39-
fn main() {
38+
#[tokio::main]
39+
async fn main() {
4040
let opts = Opts::parse();
4141

4242
let _trace_guard = Tracing::pre_configured(APP_NAME, opts.telemetry_arguments)
@@ -70,7 +70,7 @@ fn main() {
7070
}
7171
std::thread::sleep(next_run_sleep);
7272

73-
let system_information = SystemInformation::collect(&mut collect_ctx);
73+
let system_information = SystemInformation::collect(&mut collect_ctx).await;
7474

7575
let serialized = serde_json::to_string_pretty(&system_information).unwrap();
7676
if let Some(output_path) = &opts.output {

crates/containerdebug/src/system_information/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl SystemInformation {
5959

6060
/// Collects and reports
6161
#[tracing::instrument(name = "SystemInformation::collect", skip(ctx))]
62-
pub fn collect(ctx: &mut CollectContext) -> Self {
62+
pub async fn collect(ctx: &mut CollectContext) -> Self {
6363
tracing::debug!("Starting data collection");
6464

6565
let info = Self {
@@ -70,7 +70,7 @@ impl SystemInformation {
7070
user::User::collect_current(&ctx.system),
7171
)),
7272
disks: Some(disk::Disk::collect_all()),
73-
network: Some(network::SystemNetworkInfo::collect()),
73+
network: Some(network::SystemNetworkInfo::collect().await),
7474
// ..Default::default()
7575
};
7676

crates/containerdebug/src/system_information/network.rs

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
use hickory_resolver::{Resolver, system_conf::read_system_conf};
1+
use hickory_resolver::{
2+
TokioResolver, name_server::TokioConnectionProvider, system_conf::read_system_conf,
3+
};
24
use local_ip_address::list_afinet_netifas;
35
use serde::Serialize;
46
use std::{
57
collections::{BTreeSet, HashMap},
68
net::IpAddr,
9+
sync::LazyLock,
710
time::Duration,
811
};
12+
use tokio::task::JoinSet;
13+
14+
static GLOBAL_DNS_RESOLVER: LazyLock<TokioResolver> = LazyLock::new(|| {
15+
let (resolver_config, mut resolver_opts) =
16+
read_system_conf().expect("failed to read system resolv config");
17+
resolver_opts.timeout = Duration::from_secs(5);
18+
19+
TokioResolver::builder_with_config(resolver_config, TokioConnectionProvider::default())
20+
.with_options(resolver_opts)
21+
.build()
22+
});
923

1024
/// Captures all system network information, including network interfaces,
1125
/// and the results of reverse and forward DNS lookups.
@@ -18,16 +32,7 @@ pub struct SystemNetworkInfo {
1832

1933
impl SystemNetworkInfo {
2034
#[tracing::instrument(name = "SystemNetworkInfo::collect")]
21-
pub fn collect() -> SystemNetworkInfo {
22-
/*
23-
let resolver = Resolver::from_system_conf()
24-
.map_err(|e| e.to_string())
25-
.unwrap();
26-
*/
27-
let (resolver_config, mut resolver_opts) = read_system_conf().unwrap();
28-
resolver_opts.timeout = Duration::from_secs(5);
29-
let resolver = Resolver::new(resolver_config, resolver_opts).unwrap();
30-
35+
pub async fn collect() -> SystemNetworkInfo {
3136
let interfaces = match list_afinet_netifas() {
3237
Ok(netifs) => {
3338
let mut interface_map = std::collections::HashMap::new();
@@ -56,12 +61,19 @@ impl SystemNetworkInfo {
5661
}
5762
};
5863

59-
let ip_set: BTreeSet<IpAddr> = interfaces.values().flatten().copied().collect();
60-
tracing::info!(network.addresses.ip = ?ip_set, "ip addresses");
64+
let ips: BTreeSet<IpAddr> = interfaces.values().flatten().copied().collect();
65+
tracing::info!(network.addresses.ip = ?ips, "ip addresses");
6166

62-
let reverse_lookups: HashMap<IpAddr, Vec<String>> = ip_set
67+
let mut reverse_lookups = JoinSet::new();
68+
for ip in ips {
69+
reverse_lookups
70+
.spawn(async move { (ip, GLOBAL_DNS_RESOLVER.reverse_lookup(ip).await) });
71+
}
72+
let reverse_lookups: HashMap<IpAddr, Vec<String>> = reverse_lookups
73+
.join_all()
74+
.await
6375
.into_iter()
64-
.filter_map(|ip| match resolver.reverse_lookup(ip) {
76+
.filter_map(|(ip, reverse_lookup)| match reverse_lookup {
6577
Ok(result) => {
6678
let hostnames = result
6779
.into_iter()
@@ -84,9 +96,20 @@ impl SystemNetworkInfo {
8496
let hostname_set: BTreeSet<String> = reverse_lookups.values().flatten().cloned().collect();
8597
tracing::info!(network.addresses.hostname = ?hostname_set, "hostnames");
8698

87-
let forward_lookups: HashMap<String, Vec<IpAddr>> = hostname_set
99+
let mut forward_lookups = JoinSet::new();
100+
for hostname in hostname_set {
101+
forward_lookups.spawn(async move {
102+
(
103+
hostname.clone(),
104+
GLOBAL_DNS_RESOLVER.lookup_ip(hostname).await,
105+
)
106+
});
107+
}
108+
let forward_lookups: HashMap<String, Vec<IpAddr>> = forward_lookups
109+
.join_all()
110+
.await
88111
.into_iter()
89-
.filter_map(|hostname| match resolver.lookup_ip(hostname.clone()) {
112+
.filter_map(|(hostname, forward_lookup)| match forward_lookup {
90113
Ok(result) => {
91114
let ips = result.iter().collect();
92115
tracing::info!(hostname, ?ips, "performed forward DNS lookup for hostname");

0 commit comments

Comments
 (0)