Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 20, 2025

Proposed changes

Implements @after schedule keyword to handle jobs created after their intended execution time. When a job with @at 2020-01-01T00:00:00Z is created at 00:00:30 due to network latency, it never runs. The @after syntax adds a configurable grace period during which late jobs execute immediately.

Syntax:

@after 2025-01-01T00:00:00Z <PT2H

Behavior:

  • Created before scheduled time → runs at scheduled time
  • Created within grace period → runs immediately
  • Created after grace period → never runs

Implementation:

  • extcron/duration.go - ISO8601 duration parser (PT2H, P1D, P1DT2H30M)
  • extcron/after.go - AfterSchedule type with grace period logic
  • extcron/extparser.go - Parser integration for @after syntax
  • Comprehensive test coverage including boundary conditions

Example use case:

{
  "name": "maintenance-job",
  "schedule": "@after 2025-01-01T02:00:00Z <PT1H",
  "executor": "shell",
  "executor_config": {"command": "run-maintenance.sh"}
}

Job runs at 02:00 if created before, or immediately if created between 02:00-03:00. Prevents missed executions due to API latency while maintaining temporal bounds.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • client.badssl.com
    • Triggering command: /tmp/go-build4267140409/b375/http.test /tmp/go-build4267140409/b375/http.test -test.testlogfile=/tmp/go-build4267140409/b375/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build4267140409/b277/vet.cfg x64/src/runtime/-p 1xTF/_m0GZAbddpzgithub.com/mattn/go-isatty /opt/hostedtoolc-lang=go1.15 (dns block)
  • self-signed.badssl.com
    • Triggering command: /tmp/go-build4267140409/b375/http.test /tmp/go-build4267140409/b375/http.test -test.testlogfile=/tmp/go-build4267140409/b375/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build4267140409/b277/vet.cfg x64/src/runtime/-p 1xTF/_m0GZAbddpzgithub.com/mattn/go-isatty /opt/hostedtoolc-lang=go1.15 (dns block)
  • untrusted-root.badssl.com
    • Triggering command: /tmp/go-build4267140409/b375/http.test /tmp/go-build4267140409/b375/http.test -test.testlogfile=/tmp/go-build4267140409/b375/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build4267140409/b277/vet.cfg x64/src/runtime/-p 1xTF/_m0GZAbddpzgithub.com/mattn/go-isatty /opt/hostedtoolc-lang=go1.15 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Job should execute when schedule in the past</issue_title>
<issue_description>I encounter an issue that is when I try to create a job which will be execue at specific time. But some time due to network latency,... then the job is created at time greater than specific time the job should be run. So the schedule is in the past and it can not be executed. Is there any option can make dkron auto execute a job if the schedule put in the past?

Thanks.</issue_description>

<agent_instructions>Implement the solution proposed by yvanoers</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@vcastellm Currently there is no such option, some feature could be introduced like the epsilon concept that gives a time window to execute the job it is not executed for some reason but it's not currently implemented.

Anyway, jobs are created quite fast in Dkron, what time difference from the job's time do you use to create jobs? seems that it should be small. Could you post some examples?</comment_new>
<comment_new>@vcastellm
Closing for no answer</comment_new>
<comment_new>@yvanoers
It seems to me like dkron is being used somewhat like a task queue processor in this scenario.
That could actually be very useful, but it is not the intended use of a task scheduler.
So IMHO there is a risk here of adding a feature that violates the philosophy of doing one thing well.

However, as a suggestion for implementing such a thing, @Victorcoder :
What about an additional schedule keyword:
@after [RFC3339 datetime] <[ISO8601 duration]
For instance, a job with a scheduled like this:
@after 2020-01-01T00:00:00Z <P2H
would run at 2020-01-01 00:00:00 if created before then,
would run immediately if created anywhere between 00:00 and 02:00 on 2020-01-01,
would never run if created after 2020-01-01 02:00:00.

Of course, the first question to answer is whether the use case should be supported at all.</comment_new>
<comment_new>@vcastellm
I can consider implementing something like @yvanoers suggested to fix the use case of missing a job creation using a job queue.

In your case @drauschenbach, it's related but a bit different, do you think that re-triggering jobs with missed executions on becoming leader will cover your use case?

Why "a minute ago"? and not any amount of time? </comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Dec 20, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 20, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copilot/fix-job-schedule-execution

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 3 commits December 20, 2025 10:45
Co-authored-by: vcastellm <47026+vcastellm@users.noreply.github.com>
Co-authored-by: vcastellm <47026+vcastellm@users.noreply.github.com>
…ditions

Co-authored-by: vcastellm <47026+vcastellm@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix job execution when scheduled in the past Add @after schedule with grace period for late job creation Dec 20, 2025
Copilot AI requested a review from vcastellm December 20, 2025 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Job should execute when schedule in the past

2 participants