diff --git a/backend/tests/worker.rs b/backend/tests/worker.rs index 98af3a9648..48b0e15eca 100644 --- a/backend/tests/worker.rs +++ b/backend/tests/worker.rs @@ -2851,7 +2851,7 @@ async fn test_script_schedule_handlers(db: Pool) { let now = chrono::Utc::now(); // add 5 seconds to now let then = now - .checked_add_signed(chrono::Duration::seconds(5)) + .checked_add_signed(chrono::Duration::try_seconds(5).unwrap()) .unwrap(); let schedule = NewSchedule { @@ -2916,7 +2916,7 @@ async fn test_script_schedule_handlers(db: Pool) { args.insert("fail".to_string(), json!(false)); let now = chrono::Utc::now(); let then = now - .checked_add_signed(chrono::Duration::seconds(5)) + .checked_add_signed(chrono::Duration::try_seconds(5).unwrap()) .unwrap(); client .update_schedule( @@ -2995,7 +2995,7 @@ async fn test_flow_schedule_handlers(db: Pool) { let now = chrono::Utc::now(); // add 5 seconds to now let then = now - .checked_add_signed(chrono::Duration::seconds(5)) + .checked_add_signed(chrono::Duration::try_seconds(5).unwrap()) .unwrap(); let schedule = NewSchedule { @@ -3061,7 +3061,7 @@ async fn test_flow_schedule_handlers(db: Pool) { args.insert("fail".to_string(), json!(false)); let now = chrono::Utc::now(); let then = now - .checked_add_signed(chrono::Duration::seconds(5)) + .checked_add_signed(chrono::Duration::try_seconds(5).unwrap()) .unwrap(); client .update_schedule( diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index 9f8cf75938..b735ef447c 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -660,7 +660,9 @@ impl RunJobQuery { Ok(Some(scheduled_for)) } else if let Some(scheduled_in_secs) = self.scheduled_in_secs { let now = now_from_db(db).await?; - Ok(Some(now + chrono::Duration::seconds(scheduled_in_secs))) + Ok(Some( + now + chrono::Duration::try_seconds(scheduled_in_secs).unwrap_or_default(), + )) } else { Ok(None) } diff --git a/backend/windmill-api/src/users.rs b/backend/windmill-api/src/users.rs index 57553b496b..a0e724bd4d 100644 --- a/backend/windmill-api/src/users.rs +++ b/backend/windmill-api/src/users.rs @@ -305,7 +305,8 @@ impl AuthCache { key, ExpiringAuthCache { authed: authed.clone(), - expiry: chrono::Utc::now() + chrono::Duration::seconds(120), + expiry: chrono::Utc::now() + + chrono::Duration::try_seconds(120).unwrap(), }, ); } diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index 30b8151994..8ad158417d 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -777,8 +777,8 @@ pub async fn add_completed_job< .num_seconds() < 10 { - let next_run = - queued_job.started_at.unwrap_or(now) + chrono::Duration::seconds(10); + let next_run = queued_job.started_at.unwrap_or(now) + + chrono::Duration::try_seconds(10).unwrap(); tracing::warn!("Perpetual script {:?} is running too fast, only 1 job per 10s it supported. Scheduling next run for {:?}", queued_job.script_path, next_run); Some(next_run) } else { @@ -1642,8 +1642,10 @@ pub async fn pull( // optimal scheduling is: 'older_job_in_concurrency_time_window_started_timestamp + script_avg_duration + concurrency_time_window_s' let estimated_next_schedule_timestamp = min_started_at.unwrap_or(pulled_job.scheduled_for) - + Duration::seconds(avg_script_duration.map(i64::from).unwrap_or(0)) - + Duration::seconds(i64::from(job_custom_concurrency_time_window_s)); + + Duration::try_seconds(avg_script_duration.map(i64::from).unwrap_or(0)) + .unwrap_or_default() + + Duration::try_seconds(i64::from(job_custom_concurrency_time_window_s)) + .unwrap_or_default(); tracing::info!("Job '{}' from path '{}' with concurrency key '{}' has reached its concurrency limit of {} jobs run in the last {} seconds. This job will be re-queued for next execution at {}", job_uuid, job_script_path, job_custom_concurrent_limit, job_concurrency_key, job_custom_concurrency_time_window_s, estimated_next_schedule_timestamp); diff --git a/backend/windmill-worker/src/snowflake_executor.rs b/backend/windmill-worker/src/snowflake_executor.rs index 6fffc1f138..a79adcb465 100644 --- a/backend/windmill-worker/src/snowflake_executor.rs +++ b/backend/windmill-worker/src/snowflake_executor.rs @@ -119,7 +119,7 @@ pub async fn do_snowflake( iss: iss, sub: qualified_username, iat: chrono::Utc::now().timestamp(), - exp: (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp(), + exp: (chrono::Utc::now() + chrono::Duration::try_hours(1).unwrap()).timestamp(), }; let private_key = EncodingKey::from_rsa_pem(database.private_key.as_bytes()).map_err(|e| {