From 9498ab8c07dfa024ef3058d419aa7fde1e0f0601 Mon Sep 17 00:00:00 2001 From: Max Novich Date: Mon, 30 Jun 2025 10:49:18 -0700 Subject: [PATCH] fixes cron parsing issues --- crates/goose/src/scheduler.rs | 51 ++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/crates/goose/src/scheduler.rs b/crates/goose/src/scheduler.rs index d6eba4650d91..e4f290306a40 100644 --- a/crates/goose/src/scheduler.rs +++ b/crates/goose/src/scheduler.rs @@ -270,14 +270,23 @@ impl Scheduler { tracing::info!("Attempting to parse cron expression: '{}'", stored_job.cron); let normalized_cron = normalize_cron_expression(&stored_job.cron); - if normalized_cron != stored_job.cron { + // Convert from 7-field (Temporal format) to 6-field (tokio-cron-scheduler format) + let tokio_cron = { + let parts: Vec<&str> = normalized_cron.split_whitespace().collect(); + if parts.len() == 7 { + parts[..6].join(" ") + } else { + normalized_cron.clone() + } + }; + if tokio_cron != stored_job.cron { tracing::info!( - "Normalized cron expression from '{}' to '{}'", + "Converted cron expression from '{}' to '{}' for tokio-cron-scheduler", stored_job.cron, - normalized_cron + tokio_cron ); } - let cron_task = Job::new_async(&normalized_cron, move |_uuid, _l| { + let cron_task = Job::new_async(&tokio_cron, move |_uuid, _l| { let task_job_id = job_for_task.id.clone(); let current_jobs_arc = jobs_arc_for_task.clone(); let local_storage_path = storage_path_for_task.clone(); @@ -439,14 +448,23 @@ impl Scheduler { job_to_load.cron ); let normalized_cron = normalize_cron_expression(&job_to_load.cron); - if normalized_cron != job_to_load.cron { + // Convert from 7-field (Temporal format) to 6-field (tokio-cron-scheduler format) + let tokio_cron = { + let parts: Vec<&str> = normalized_cron.split_whitespace().collect(); + if parts.len() == 7 { + parts[..6].join(" ") + } else { + normalized_cron.clone() + } + }; + if tokio_cron != job_to_load.cron { tracing::info!( - "Normalized cron expression from '{}' to '{}'", + "Converted cron expression from '{}' to '{}' for tokio-cron-scheduler", job_to_load.cron, - normalized_cron + tokio_cron ); } - let cron_task = Job::new_async(&normalized_cron, move |_uuid, _l| { + let cron_task = Job::new_async(&tokio_cron, move |_uuid, _l| { let task_job_id = job_for_task.id.clone(); let current_jobs_arc = jobs_arc_for_task.clone(); let local_storage_path = storage_path_for_task.clone(); @@ -810,14 +828,23 @@ impl Scheduler { new_cron ); let normalized_cron = normalize_cron_expression(&new_cron); - if normalized_cron != new_cron { + // Convert from 7-field (Temporal format) to 6-field (tokio-cron-scheduler format) + let tokio_cron = { + let parts: Vec<&str> = normalized_cron.split_whitespace().collect(); + if parts.len() == 7 { + parts[..6].join(" ") + } else { + normalized_cron.clone() + } + }; + if tokio_cron != new_cron { tracing::info!( - "Normalized cron expression from '{}' to '{}'", + "Converted cron expression from '{}' to '{}' for tokio-cron-scheduler", new_cron, - normalized_cron + tokio_cron ); } - let cron_task = Job::new_async(&normalized_cron, move |_uuid, _l| { + let cron_task = Job::new_async(&tokio_cron, move |_uuid, _l| { let task_job_id = job_for_task.id.clone(); let current_jobs_arc = jobs_arc_for_task.clone(); let local_storage_path = storage_path_for_task.clone();