diff --git a/backend/windmill-api-schedule/src/lib.rs b/backend/windmill-api-schedule/src/lib.rs index 460c2607cd..e891f84dde 100644 --- a/backend/windmill-api-schedule/src/lib.rs +++ b/backend/windmill-api-schedule/src/lib.rs @@ -1010,8 +1010,8 @@ pub struct ScheduleWJobs { pub queues_next_run_at_start: bool, } -/// Occurrences to look ahead over when sizing the interval. -const INTERVAL_SAMPLE_SLOTS: usize = 5; +/// Scheduled events to look ahead over when sizing the interval. +const INTERVAL_SAMPLE_EVENTS: usize = 5; /// The *shortest* gap, not the average: under an irregular expression a run can /// outlast the tight gaps while still fitting inside the mean, and it is the @@ -1023,8 +1023,8 @@ fn configured_interval_s( ) -> Option { let tz = chrono_tz::Tz::from_str(timezone).ok()?; let cron = ScheduleType::from_str(schedule, cron_version, false).ok()?; - let slots = cron.upcoming(tz, INTERVAL_SAMPLE_SLOTS).ok()?; - slots + let events = cron.upcoming(tz, INTERVAL_SAMPLE_EVENTS).ok()?; + events .windows(2) .map(|pair| (pair[1] - pair[0]).num_seconds()) .min() @@ -1753,7 +1753,7 @@ mod tests { use super::*; /// Twice a day, so the gaps alternate 8 hours and 16. A run only has to - /// outlast the shorter one to start skipping slots, so that is the number + /// outlast the shorter one to start skipping events, so that is the number /// the interval has to be. #[test] fn interval_is_the_shortest_gap_an_irregular_cron_leaves() { diff --git a/frontend/src/lib/components/schedules/scheduleDrift.test.ts b/frontend/src/lib/components/schedules/scheduleDrift.test.ts index c170712552..df41de1457 100644 --- a/frontend/src/lib/components/schedules/scheduleDrift.test.ts +++ b/frontend/src/lib/components/schedules/scheduleDrift.test.ts @@ -5,9 +5,9 @@ const runs = (duration_ms: number) => Array.from({ length: 5 }, () => ({ duratio // Each exemption below is a schedule that is genuinely running less often than // its cron reads, and is still not something to report. Losing one of them turns -// the badge into noise on a correctly configured schedule. +// the warning into noise on a correctly configured schedule. describe('runsOutlastingInterval', () => { - it('reports how long runs that outlast the gap between slots are taking', () => { + it('reports how long runs that outlast the gap between events are taking', () => { expect(runsOutlastingInterval({ enabled: true, interval_s: 20, jobs: runs(50_000) })).toBe( 50_000 ) diff --git a/frontend/src/lib/components/schedules/scheduleDrift.ts b/frontend/src/lib/components/schedules/scheduleDrift.ts index b4b54f44ee..ff0444b8d8 100644 --- a/frontend/src/lib/components/schedules/scheduleDrift.ts +++ b/frontend/src/lib/components/schedules/scheduleDrift.ts @@ -10,11 +10,11 @@ export type ScheduleRunsSample = { /** * How long a schedule's runs have been taking, when that is longer than the gap - * between its slots, and `undefined` otherwise. + * between its scheduled events, and `undefined` otherwise. * * A plain script schedule queues its next run only once the previous one has * completed, so a run that outlasts the interval necessarily pushes the next one - * to a later slot: the schedule quietly runs less often than its cron says. + * to a later event: the schedule quietly runs less often than its cron says. * Schedules that queue the next run as the previous one starts are exempt, and * the server says which those are. */ diff --git a/frontend/src/lib/components/triggers/schedules/ScheduleEditorInner.svelte b/frontend/src/lib/components/triggers/schedules/ScheduleEditorInner.svelte index 8c3a190ee1..dd02b5b301 100644 --- a/frontend/src/lib/components/triggers/schedules/ScheduleEditorInner.svelte +++ b/frontend/src/lib/components/triggers/schedules/ScheduleEditorInner.svelte @@ -946,7 +946,7 @@ Recent runs have been taking about {msToReadableTimeShort(outlastingMs, 0)}, against {msToReadableTime( runsSample.interval_s * 1000 - )} between slots. Script runs never overlap, so the next run is only queued once the + )} between scheduled events. Script runs never overlap, so the next run is only queued once the previous one has completed: this schedule is running less often than its cron asks for. To keep the cadence, schedule a flow instead, which queues its next run when the previous one starts.