From 4dc1773dc7cb0701fac89883bcb3e41f3e482c9d Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 12 Apr 2023 20:06:50 +0200 Subject: [PATCH] fix(backend): do not fail on schedule not existing anymore --- backend/windmill-worker/src/jobs.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/backend/windmill-worker/src/jobs.rs b/backend/windmill-worker/src/jobs.rs index 5008620015..826d96859b 100644 --- a/backend/windmill-worker/src/jobs.rs +++ b/backend/windmill-worker/src/jobs.rs @@ -223,14 +223,17 @@ pub async fn schedule_again_if_scheduled<'c, R: rsmq_async::RsmqConnection + Clo script_path: &str, w_id: &str, ) -> windmill_common::error::Result> { - let schedule = get_schedule_opt(tx.transaction_mut(), w_id, schedule_path) - .await? - .ok_or_else(|| { - Error::InternalErr(format!( - "Could not find schedule {:?} for workspace {}", - schedule_path, w_id - )) - })?; + let schedule = get_schedule_opt(tx.transaction_mut(), w_id, schedule_path).await?; + + if schedule.is_none() { + tracing::error!( + "Schedule {schedule_path} in {w_id} not found. Impossible to schedule again" + ); + return Ok(tx); + } + + let schedule = schedule.unwrap(); + if schedule.enabled && script_path == schedule.script_path { let res = windmill_queue::schedule::push_scheduled_job( tx,