Skip to content

Commit

Permalink
Do not transmit pid 0 as the target pid (#1087)
Browse files Browse the repository at this point in the history
### What does this PR do?

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.
  • Loading branch information
blt authored Nov 4, 2024
1 parent c717ca4 commit d6b73d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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 d6b73d5

Please sign in to comment.