Skip to content

Commit

Permalink
Do not transmit pid 0 as the target pid
Browse files Browse the repository at this point in the history
In some cases docker will report that the pid of a new container is 0.
This is not a usable pid and we believe it is a race condition. Loop
around again in this even, logging.

Signed-off-by: Brian L. Troutwine <[email protected]>
  • Loading branch information
blt committed Nov 4, 2024
1 parent c717ca4 commit fb20326
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lading/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit fb20326

Please sign in to comment.