Skip to content

Commit 12e1d0b

Browse files
committed
agent: do not fail job if a non-critical file is removed before upload
1 parent da6d899 commit 12e1d0b

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,10 @@ Configuration properties supported for basic jobs include:
504504
artefacts. If the size or modified time of a file changes while it is being
505505
uploaded, the job will fail. To relax this restriction, the `%` prefix may
506506
be used to signify that "this file is allowed to change while it is being
507-
uploaded". This is used to make best effort uploads of diagnostic log files
508-
for background processes which may continue running even though the job is
509-
nominally complete; e.g.,
507+
uploaded". The `%` prefix will also ignore a file that is completely removed
508+
by a background process before it is able to be uploaded. This is used to
509+
make best effort uploads of diagnostic log files for background processes
510+
which may continue running even though the job is nominally complete; e.g.,
510511

511512
```bash
512513
#: output_rules = [

agent/src/upload.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use std::collections::HashSet;
66
use std::fs;
7-
use std::io::Read;
7+
use std::io::{ErrorKind, Read};
88
use std::path::{Path, PathBuf};
99

1010
use tokio::sync::mpsc;
@@ -227,6 +227,23 @@ pub(crate) fn upload(
227227
let mut f = match fs::File::open(&u.path) {
228228
Ok(f) => f,
229229
Err(e) => {
230+
if change_ok && e.kind() == ErrorKind::NotFound {
231+
/*
232+
* If this file is marked as being a potentially
233+
* fluctuating log file, we'll allow it to be completely
234+
* absent without raising a fatal error. It may have
235+
* been removed by some background process between when
236+
* we scanned the file system and when we went to upload
237+
* it.
238+
*/
239+
let msg = format!(
240+
"file {:?} disappeared between scan and upload",
241+
u.path,
242+
);
243+
upl.tx.send(Activity::Warning(msg)).await.unwrap();
244+
continue;
245+
}
246+
230247
upl.tx
231248
.send(Activity::Error(format!(
232249
"open {:?} failed: {:?}",

0 commit comments

Comments
 (0)