Skip to content

Commit

Permalink
Bump to cernan 0.7.5
Browse files Browse the repository at this point in the history
This release contains fixes for the overlong holding of file
descriptors in a couple of spots inside of cernan:

  * 07d3fad :: drop unused structures after cernan boot
  * de747e1 :: drop deleted files from polling in file source

The first change allows hopper to drop file descriptors opened
as a part of cernan startup. The second change allows the file source
to drop file descriptors as soon as the files are marked deleted.
Previously we assumed that this could be avoided on the expectation
of applications creating a new logfile. This assumption was not
valid.

Signed-off-by: Brian L. Troutwine <blt@postmates.com>
  • Loading branch information
Brian L. Troutwine committed Sep 11, 2017
1 parent de747e1 commit cc1e5b7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MIT"
name = "cernan"
readme = "README.md"
repository = "https://github.com/postmates/cernan"
version = "0.7.5-pre"
version = "0.7.5"

[[bin]]
name = "cernan"
Expand Down
37 changes: 15 additions & 22 deletions src/source/file/file_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,28 +118,21 @@ impl Source for FileServer {
// line polling
for (path, mut watcher) in fp_map.drain() {
let mut lines_read: usize = 0;
loop {
match watcher.read_line(&mut buffer) {
Ok(sz) => {
if sz > 0 {
lines_read += 1;
lines.push(
metric::LogLine::new(
path.to_str().expect("not a valid path"),
&buffer,
).overlay_tags_from_map(&self.tags),
);
buffer.clear();
} else {
break;
}
if lines_read > self.max_lines_read {
break;
}
}
_ => {
break;
}
while let Ok(sz) = watcher.read_line(&mut buffer) {
if sz > 0 {
lines_read += 1;
lines.push(
metric::LogLine::new(
path.to_str().expect("not a valid path"),
&buffer,
).overlay_tags_from_map(&self.tags),
);
buffer.clear();
} else {
break;
}
if lines_read > self.max_lines_read {
break;
}
}
report_full_telemetry(
Expand Down
13 changes: 4 additions & 9 deletions src/source/file/file_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ impl FileWatcher {
/// up to some maximum but unspecified amount of time. `read_line` will open
/// a new file handler at need, transparently to the caller.
pub fn read_line(&mut self, mut buffer: &mut String) -> io::Result<usize> {
if self.reopen {
if self.file_id() != self.file_id {
self.open_at_start();
}
if self.reopen && self.file_id() != self.file_id {
self.open_at_start();
}
if let Some(ref mut reader) = self.reader {
// match here on error, if metadata doesn't match up open_at_start
Expand All @@ -115,11 +113,8 @@ impl FileWatcher {
Ok(buffer.len())
}
Err(e) => {
match e.kind() {
io::ErrorKind::NotFound => {
self.reopen = true;
}
_ => {}
if let io::ErrorKind::NotFound = e.kind() {
self.reopen = true;
}
Err(e)
}
Expand Down

0 comments on commit cc1e5b7

Please sign in to comment.