Skip to content

Commit

Permalink
Handle new jobstats format (#69)
Browse files Browse the repository at this point in the history
* Handle new jobstats format

* Update lustrefs-exporter/src/jobstats.rs

* Update lustrefs-exporter/src/jobstats.rs

---------

Co-authored-by: Joe Grund <jgrund@whamcloud.io>
  • Loading branch information
RDruon and jgrund authored Aug 8, 2024
1 parent cf16c26 commit bf6a96c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lustrefs-exporter/fixtures/jobstats_only/2.14.0_162.txt
Git LFS file not shown
26 changes: 24 additions & 2 deletions lustrefs-exporter/src/jobstats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ pub fn jobstats_stream<R: BufRead + std::marker::Send + 'static>(
let line = maybe_line?;

match state {
_ if line == "job_stats:" || line.starts_with(" snapshot_time:") => {
_ if line == "job_stats:"
|| line.starts_with(" start_time:")
|| line.starts_with(" elapsed_time:")
|| line.starts_with(" snapshot_time:") =>
{
return Ok((state, LoopInstruction::Noop))
}
State::Empty if line.starts_with("obdfilter") || line.starts_with("mdt.") => {
Expand Down Expand Up @@ -118,7 +122,6 @@ pub fn jobstats_stream<R: BufRead + std::marker::Send + 'static>(
}
x => {
tracing::debug!("Unexpected line: {line}, state: {x:?}");

return Ok((x, LoopInstruction::Return));
}
}
Expand Down Expand Up @@ -352,6 +355,25 @@ pub mod tests {
assert_eq!(cnt, 5_310_036);
}

#[tokio::test(flavor = "multi_thread")]
async fn parse_new_yaml() {
let f = File::open("fixtures/jobstats_only/2.14.0_162.txt").unwrap();

let f = BufReader::with_capacity(128 * 1_024, f);

let (fut, mut rx) = jobstats_stream(f);

let mut cnt = 0;

while rx.recv().await.is_some() {
cnt += 1;
}

fut.await.unwrap();

assert_eq!(cnt, 1_728);
}

const JOBSTAT_JOB: &str = r#"
- job_id: "FAKE_JOB"
snapshot_time: 1720516680
Expand Down

0 comments on commit bf6a96c

Please sign in to comment.