Skip to content

Commit d6b73d5

Browse files
authored
Do not transmit pid 0 as the target pid (#1087)
### 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.
1 parent c717ca4 commit d6b73d5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## Unreleased
8+
### Fixed
9+
- Target pid watcher will not report 0 for containers.
10+
711
## [0.23.4]
812
### Added
913
- Introduced logrotate_fs, a sub-generator of `file_gen` that exposes a FUSE

lading/src/target.rs

+11
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,17 @@ impl Server {
261261
let pid: i64 = loop {
262262
if let Ok(container) = docker.inspect_container(&config.name, None).await {
263263
if let Some(pid) = container.state.and_then(|state| state.pid) {
264+
// In some cases docker will report pid 0 as the pid for the
265+
// polled container. This is not usable by us and we believe
266+
// a race condition.
267+
if pid == 0 {
268+
info!(
269+
"Found container with name {name} but with pid {pid}. Polling.",
270+
name = config.name
271+
);
272+
time::sleep(Duration::from_secs(1)).await;
273+
continue;
274+
}
264275
break pid;
265276
}
266277
} else {

0 commit comments

Comments
 (0)