Skip to content

Commit

Permalink
Log job errors
Browse files Browse the repository at this point in the history
  • Loading branch information
augustuswm committed Nov 8, 2023
1 parent 97d64b0 commit 75a8032
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
37 changes: 19 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions rfd-processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
12 changes: 10 additions & 2 deletions rfd-processor/src/processor.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use futures::TryFutureExt;
use rfd_model::storage::{JobFilter, JobStore, ListPagination, StoreError};
use std::sync::Arc;
use tap::TapFallible;
Expand Down Expand Up @@ -34,8 +35,10 @@ pub async fn processor(ctx: Arc<Context>) -> 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)) => {
Expand Down Expand Up @@ -83,7 +86,12 @@ pub async fn processor(ctx: Arc<Context>) -> Result<(), JobError> {
}

Ok::<_, JobError>(())
});
}.or_else(move |err| {
async move {
tracing::error!(id = ?job_id, ?err, "Spawned job failed");
Err(err)
}
}));
}
}

Expand Down

0 comments on commit 75a8032

Please sign in to comment.