Skip to content

Commit

Permalink
Merge branch 'main' into fix-dedicated-worker-multipy
Browse files Browse the repository at this point in the history
  • Loading branch information
pyranota authored Feb 20, 2025
2 parents 44fea55 + c90fe38 commit 2290a07
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/ee-repo-ref.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b5f4243f5649d972e8722ce134c7cf5256d131d6
2bb902449b6df37a6a81989ce98f4a12716a01d6
7 changes: 4 additions & 3 deletions backend/windmill-api/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ async fn create_schedule(
let mut tx: Transaction<'_, Postgres> = user_db.begin(&authed).await?;

// Check schedule for error
ScheduleType::from_str(&ns.schedule, ns.cron_version.as_deref())?;
ScheduleType::from_str(&ns.schedule, ns.cron_version.as_deref(), true)?;

check_path_conflict(&mut tx, &w_id, &ns.path).await?;
check_flow_conflict(&mut tx, &w_id, &ns.path, ns.is_flow, &ns.script_path).await?;
Expand Down Expand Up @@ -249,7 +249,7 @@ async fn edit_schedule(
let mut tx = user_db.begin(&authed).await?;

// Check schedule for error
ScheduleType::from_str(&es.schedule, es.cron_version.as_deref())?;
ScheduleType::from_str(&es.schedule, es.cron_version.as_deref(), true)?;

clear_schedule(&mut tx, path, &w_id).await?;
let schedule = sqlx::query_as::<_, Schedule>(
Expand Down Expand Up @@ -468,7 +468,8 @@ pub struct PreviewPayload {
pub async fn preview_schedule(
Json(payload): Json<PreviewPayload>,
) -> JsonResult<Vec<DateTime<Utc>>> {
let schedule = ScheduleType::from_str(&payload.schedule, payload.cron_version.as_deref())?;
let schedule =
ScheduleType::from_str(&payload.schedule, payload.cron_version.as_deref(), true)?;

let tz =
chrono_tz::Tz::from_str(&payload.timezone).map_err(|e| Error::BadRequest(e.to_string()))?;
Expand Down
14 changes: 12 additions & 2 deletions backend/windmill-common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,11 @@ impl ScheduleType {
}
}

pub fn from_str(schedule_str: &str, version: Option<&str>) -> Result<ScheduleType> {
pub fn from_str(
schedule_str: &str,
version: Option<&str>,
seconds_required: bool,
) -> Result<ScheduleType> {
tracing::debug!(
"Attempting to parse schedule string: {}, with version: {:?}",
schedule_str,
Expand All @@ -448,7 +452,13 @@ impl ScheduleType {
Some("v2") | Some(_) => {
// Use Croner for v2
let schedule_type_result = panic::catch_unwind(AssertUnwindSafe(|| {
Cron::new(schedule_str).with_seconds_optional().parse()
let mut croner = Cron::new(schedule_str);
if seconds_required {
croner.with_seconds_required();
} else {
croner.with_seconds_optional();
};
croner.parse()
}))
.map_err(|_| {
tracing::error!(
Expand Down
3 changes: 2 additions & 1 deletion backend/windmill-queue/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ pub async fn push_scheduled_job<'c>(
));
}

let sched = ScheduleType::from_str(&schedule.schedule, schedule.cron_version.as_deref())?;
let sched =
ScheduleType::from_str(&schedule.schedule, schedule.cron_version.as_deref(), false)?;

let tz = chrono_tz::Tz::from_str(&schedule.timezone)
.map_err(|e| error::Error::BadRequest(e.to_string()))?;
Expand Down

0 comments on commit 2290a07

Please sign in to comment.