fix(cron): use host timezone for conversation cron#652
Open
tcp404 wants to merge 1 commit into
Open
Conversation
`cron current create` builds a schedule from a bare cron expression
whose description refers to local wall-clock time ("every day at
12:00"), but stored no timezone. The scheduler resolves an absent tz
as UTC, so on any non-UTC host the job fired at the wrong hour.
Stamp the host's local IANA zone (via iana-time-zone) onto the
conversation schedule, falling back to UTC only when the zone cannot
be detected. The scheduler default is left unchanged: the frontend
already sends an explicit tz, so no other create path is affected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
cron current create(the conversation-helper CLI path) builds a schedule from a bare cron expression whose description refers to local wall-clock time (e.g. "every day at 12:00"), but stored no timezone. The scheduler resolves an absent tz as UTC, so on any non-UTC host the job fired at the wrong hour.Reproduced on a UTC+8 host:
0 0 12 * * *("daily at 12:00") computed its next run at 20:00 local (= 12:00 UTC), 8 hours off from what the schedule description promised.Fix
Stamp the host's local IANA zone (via
iana-time-zone, already a transitive dep ofchrono) onto the conversation schedule, falling back to UTC only when the zone cannot be detected or is not in the tz database.Scope is confined to the conversation-helper path:
/api/cron/jobspath already sends an explicit tz, so no other create path is affected.local_timezone_name()+conversation_cron_schedule()inaionui-cron/service.rs.Tests
conversation_cron_wires_local_timezone— deterministic: stamped tz is non-None and a valid IANA zone.conversation_cron_fires_at_local_wall_clock— the schedule fires at 12:00 local wall-clock (guarded to skip when the host zone is undetectable).cargo test -p aionui-cron: 184 lib + 73 integration pass; clippy-D warningsand fmt clean.