Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Better logging of failure in the task_logger (#2940)
Browse files Browse the repository at this point in the history
* logging task_logger failure

* format

* clippy fxes

* cleanup

* address comments
  • Loading branch information
chkeita authored Apr 6, 2023
1 parent f19a0e8 commit d27d815
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/agent/onefuzz-agent/src/validations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ async fn validate_libfuzzer(config: ValidationConfig) -> Result<()> {
let libfuzzer = LibFuzzer::new(
&config.target_exe,
config.target_options.clone(),
config.target_env.into_iter().collect(),
config.target_env.iter().cloned().collect(),
config
.setup_folder
.unwrap_or(config.target_exe.parent().unwrap().to_path_buf()),
.clone()
.or_else(|| config.target_exe.parent().map(|p| p.to_path_buf()))
.expect("invalid target_exe"),
None::<&PathBuf>,
MachineIdentity {
machine_id: Uuid::nil(),
Expand Down Expand Up @@ -103,10 +105,12 @@ async fn get_logs(config: ValidationConfig) -> Result<()> {
let libfuzzer = LibFuzzer::new(
&config.target_exe,
config.target_options.clone(),
config.target_env.into_iter().collect(),
config.target_env.iter().cloned().collect(),
config
.setup_folder
.unwrap_or(config.target_exe.parent().unwrap().to_path_buf()),
.clone()
.or_else(|| config.target_exe.parent().map(|p| p.to_path_buf()))
.expect("invalid setup_folder"),
None::<&PathBuf>,
MachineIdentity {
machine_id: Uuid::nil(),
Expand Down
9 changes: 6 additions & 3 deletions src/agent/onefuzz-task/src/tasks/task_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ impl TaskLogger {
}) => break,
Ok(c) => c,
Err(e) => {
error!("{}", e);
break;
error!("task logger failure {}", e);
return Err(e);
}
};
}
Expand All @@ -440,7 +440,10 @@ pub struct SpawnedLogger {

impl SpawnedLogger {
pub async fn flush_and_stop(self, timeout: Duration) -> Result<()> {
let _ = tokio::time::timeout(timeout, self.logger_handle).await;
if let Ok(Err(e)) = tokio::time::timeout(timeout, self.logger_handle).await {
error!("failed to flush and stop task logger {}", e);
return Err(e.into());
}
Ok(())
}
}
Expand Down

0 comments on commit d27d815

Please sign in to comment.