From 83e636a27a9067b293217d65c990d8f5fd09acdb Mon Sep 17 00:00:00 2001 From: Kanan Boubion Date: Wed, 25 Oct 2023 11:25:57 -0700 Subject: [PATCH 1/4] 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 7c7bc815a5..9665f8d2c5 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; From 48c45cfb8f4c766939a741b4643dd4b69895470d Mon Sep 17 00:00:00 2001 From: Kanan Boubion Date: Wed, 25 Oct 2023 15:20:41 -0700 Subject: [PATCH 2/4] cargo fmt --- src/agent/onefuzz-task/src/managed/cmd.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/agent/onefuzz-task/src/managed/cmd.rs b/src/agent/onefuzz-task/src/managed/cmd.rs index 9665f8d2c5..fef3c68c4b 100644 --- a/src/agent/onefuzz-task/src/managed/cmd.rs +++ b/src/agent/onefuzz-task/src/managed/cmd.rs @@ -129,7 +129,10 @@ pub async fn run(args: &clap::ArgMatches) -> Result<()> { 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); + info!( + "check out the documentation on this error for more information: {}", + doc_url + ); } } From fef19a860987be17dbc52afe08c2f4e4b2f6c0be Mon Sep 17 00:00:00 2001 From: Kanan Boubion Date: Wed, 25 Oct 2023 15:25:38 -0700 Subject: [PATCH 3/4] Fix variable name --- src/agent/onefuzz-task/src/managed/cmd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agent/onefuzz-task/src/managed/cmd.rs b/src/agent/onefuzz-task/src/managed/cmd.rs index fef3c68c4b..412c93a886 100644 --- a/src/agent/onefuzz-task/src/managed/cmd.rs +++ b/src/agent/onefuzz-task/src/managed/cmd.rs @@ -128,7 +128,7 @@ pub async fn run(args: &clap::ArgMatches) -> Result<()> { if let Err(err) = &result { error!("error running task: {:?}", err); - if let Some(doc_url) = doc_url { + if let Some(doc_url) = error_documentation { info!( "check out the documentation on this error for more information: {}", doc_url From b79b1213f536e55eb4f982345024009361c9c348 Mon Sep 17 00:00:00 2001 From: Kanan Boubion Date: Mon, 30 Oct 2023 16:30:14 -0700 Subject: [PATCH 4/4] Add real link to docs for task OOM --- src/agent/onefuzz-task/src/managed/cmd.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agent/onefuzz-task/src/managed/cmd.rs b/src/agent/onefuzz-task/src/managed/cmd.rs index 412c93a886..520651f645 100644 --- a/src/agent/onefuzz-task/src/managed/cmd.rs +++ b/src/agent/onefuzz-task/src/managed/cmd.rs @@ -117,7 +117,7 @@ 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"); + error_documentation = Some("https://eng.ms/docs/cloud-ai-platform/azure-edge-platform-aep/aep-security/epsf-edge-and-platform-security-fundamentals/the-onefuzz-service/onefuzz/howto/understanding-task-oom"); Err(err) }, @@ -130,7 +130,7 @@ pub async fn run(args: &clap::ArgMatches) -> Result<()> { error!("error running task: {:?}", err); if let Some(doc_url) = error_documentation { info!( - "check out the documentation on this error for more information: {}", + "check out the documentation for more info about the error above: {}", doc_url ); }