diff options
| author | Hazel Atkinson <yellowsink@riseup.net> | 2025-04-07 13:43:12 +0100 |
|---|---|---|
| committer | Hazel Atkinson <yellowsink@riseup.net> | 2025-04-07 13:43:12 +0100 |
| commit | cd5fbac13f68d2e054632570bb3520f9a3ff8e42 (patch) | |
| tree | 18d177cb4affe5baaa8e1c119ecdfc5b5f995647 /src/stats_task.rs | |
| parent | fbbefe8d4341df7796aefae772ad335359c3b232 (diff) | |
| download | containerspy-cd5fbac13f68d2e054632570bb3520f9a3ff8e42.tar.gz containerspy-cd5fbac13f68d2e054632570bb3520f9a3ff8e42.tar.bz2 containerspy-cd5fbac13f68d2e054632570bb3520f9a3ff8e42.zip | |
cleanups, make workers close neatly on container exit
Diffstat (limited to 'src/stats_task.rs')
| -rw-r--r-- | src/stats_task.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/stats_task.rs b/src/stats_task.rs index 4240a63..8b82373 100644 --- a/src/stats_task.rs +++ b/src/stats_task.rs @@ -1,5 +1,5 @@ use std::mem::MaybeUninit; -use bollard::container::{BlkioStats, BlkioStatsEntry, StatsOptions}; +use bollard::container::{BlkioStatsEntry, StatsOptions}; use bollard::models::ContainerSummary; use bollard::Docker; use opentelemetry::metrics::MeterProvider; @@ -136,6 +136,19 @@ pub fn launch_stats_task( while let Some(val) = stats_stream.next().await { if let Ok(stats) = val { + + // when a container exits, instead of a None we get sent Ok()s with zeroes in it forever, horror + if stats.cpu_stats.cpu_usage.total_usage == 0 { + if stats.precpu_stats.cpu_usage.total_usage != 0 { break; } + else { + // last time was ALSO a zero, so this MIGHT actually be (SOMEHOW?) legit, + // so just loop around again, and wait for the main task to abort() this worker task instead! + // which it will if this container died, or if we are gonna get real stats later, it won't... + // man i dont know i should probably just break lol + continue; + } + }; + meter_container_cpu_usage_seconds_total.add( cpu_delta_from_docker( stats.cpu_stats.cpu_usage.total_usage, |
