From 75a8032d181fcd6435cda99b2e06be615eecf6db Mon Sep 17 00:00:00 2001 From: augustuswm Date: Wed, 8 Nov 2023 08:22:55 -0600 Subject: [PATCH] Log job errors --- Cargo.lock | 37 +++++++++++++++++----------------- Cargo.toml | 1 + rfd-processor/Cargo.toml | 1 + rfd-processor/src/processor.rs | 12 +++++++++-- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d47814a..9a5c843 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -844,9 +844,9 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -859,9 +859,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -869,15 +869,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -886,15 +886,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", @@ -903,15 +903,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-timer" @@ -921,9 +921,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -2570,6 +2570,7 @@ dependencies = [ "chrono", "config", "diesel", + "futures", "google-drive3", "google-storage1", "hex", diff --git a/Cargo.toml b/Cargo.toml index 2f752f2..217908b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ diesel = { version = "2.1.3", features = ["postgres"] } dirs = "5.0.1" dropshot = { git = "https://github.com/oxidecomputer/dropshot" } dropshot-verified-body = { git = "https://github.com/oxidecomputer/dropshot-verified-body", branch = "dropshot-dev" } +futures = "0.3.29" google-cloudkms1 = "5.0.3" google-drive3 = "5.0.3" google-storage1 = "5.0.3" diff --git a/rfd-processor/Cargo.toml b/rfd-processor/Cargo.toml index 336c73f..410d235 100644 --- a/rfd-processor/Cargo.toml +++ b/rfd-processor/Cargo.toml @@ -11,6 +11,7 @@ base64 = { workspace = true } chrono = { workspace = true } config = { workspace = true } diesel = { workspace = true } +futures = { workspace = true } google-drive3 = { workspace = true } google-storage1 = { workspace = true } hex = { workspace = true } diff --git a/rfd-processor/src/processor.rs b/rfd-processor/src/processor.rs index f81f98c..e3476a3 100644 --- a/rfd-processor/src/processor.rs +++ b/rfd-processor/src/processor.rs @@ -1,3 +1,4 @@ +use futures::TryFutureExt; use rfd_model::storage::{JobFilter, JobStore, ListPagination, StoreError}; use std::sync::Arc; use tap::TapFallible; @@ -34,8 +35,10 @@ pub async fn processor(ctx: Arc) -> Result<(), JobError> { .await?; for job in jobs { + let job_id = job.id; + let ctx = ctx.clone(); - let res = tokio::spawn(async move { + tokio::spawn(async move { // Make the job as started match JobStore::start(&ctx.db.storage, job.id).await { Ok(Some(job)) => { @@ -83,7 +86,12 @@ pub async fn processor(ctx: Arc) -> Result<(), JobError> { } Ok::<_, JobError>(()) - }); + }.or_else(move |err| { + async move { + tracing::error!(id = ?job_id, ?err, "Spawned job failed"); + Err(err) + } + })); } }