diff --git a/CHANGELOG.md b/CHANGELOG.md index d5a29cfba..abba411e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +### Fixed +- Target pid watcher will not report 0 for containers. + ## [0.23.4] ### Added - Introduced logrotate_fs, a sub-generator of `file_gen` that exposes a FUSE diff --git a/lading/src/target.rs b/lading/src/target.rs index 4eda9dd07..d2dba6852 100644 --- a/lading/src/target.rs +++ b/lading/src/target.rs @@ -261,6 +261,17 @@ impl Server { let pid: i64 = loop { if let Ok(container) = docker.inspect_container(&config.name, None).await { if let Some(pid) = container.state.and_then(|state| state.pid) { + // In some cases docker will report pid 0 as the pid for the + // polled container. This is not usable by us and we believe + // a race condition. + if pid == 0 { + info!( + "Found container with name {name} but with pid {pid}. Polling.", + name = config.name + ); + time::sleep(Duration::from_secs(1)).await; + continue; + } break pid; } } else {