From 83e636a27a9067b293217d65c990d8f5fd09acdb Mon Sep 17 00:00:00 2001 From: Kanan Boubion Date: Wed, 25 Oct 2023 11:25:57 -0700 Subject: [PATCH] Add room for a link to documentation on OOM task failure --- src/agent/onefuzz-task/src/managed/cmd.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/agent/onefuzz-task/src/managed/cmd.rs b/src/agent/onefuzz-task/src/managed/cmd.rs index 7c7bc815a..9665f8d2c 100644 --- a/src/agent/onefuzz-task/src/managed/cmd.rs +++ b/src/agent/onefuzz-task/src/managed/cmd.rs @@ -96,14 +96,19 @@ pub async fn run(args: &clap::ArgMatches) -> Result<()> { let min_available_memory_bytes = 1_000_000 * config.common().min_available_memory_mb; + let mut error_documentation: Option<&str> = None; let result = match min_available_memory_bytes { 0 => { log::info!("memory watchdog is disabled: this task may fail suddenly if it runs out of memory."); - config.run().await + + tokio::select! { + result = config.run() => result, + + _shutdown = shutdown_listener => Ok(()), + } } - _ => { - // If the memory limit is 0, this will never return. - let check_oom = out_of_memory(min_available_memory_bytes); + min_bytes => { + let check_oom = out_of_memory(min_bytes); tokio::select! { result = config.run() => result, @@ -112,18 +117,20 @@ pub async fn run(args: &clap::ArgMatches) -> Result<()> { Ok(oom) = check_oom => { // Convert the OOM notification to an error, so we can log it below. let err = anyhow::format_err!("out of memory: {} bytes available, {} required", oom.available_bytes, oom.min_bytes); + error_documentation = Some("https://aka.ms/onefuzz-documentation"); Err(err) }, - _shutdown = shutdown_listener => { - Ok(()) - } + _shutdown = shutdown_listener => Ok(()), } } }; if let Err(err) = &result { error!("error running task: {:?}", err); + if let Some(doc_url) = doc_url { + info!("check out the documentation on this error for more information: {}", doc_url); + } } onefuzz_telemetry::try_flush_and_close().await;