Skip to content

[8.19] Support rrule for task scheduling (#217728)#220657

Merged
ersin-erdal merged 3 commits intoelastic:8.19from
ersin-erdal:backport/8.19/pr-217728
May 14, 2025
Merged

[8.19] Support rrule for task scheduling (#217728)#220657
ersin-erdal merged 3 commits intoelastic:8.19from
ersin-erdal:backport/8.19/pr-217728

Conversation

@ersin-erdal
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

Resolves: elastic#216308

This PR adds rrule notation support to the task scheduling.

Currently we use a simple interval string (such as `1h` or `45m`) to
calculate the next `runAt` that we use to decide if the task should be
picked up or not. With this PR, we will be able to use rrule as well.

We set the `runAt` field in 3 places:
- At task creation: when the task is created for the first time, this is
always `now` if a specific runAt is not provided.
- At task update. We update runAt on task update as well but only when
it is provided. We don't update it when the schedule config changes.
- After task run: to decide when the next run will be after a task is
run.

This PR modifies:
- At task creation: It still uses the `runAt` when it is provided but
calculates a runAt by using rrule if the config has a fixed time (like
every day at 13:00) config. Becausethe task should not run immediately
when there is a fixed time to run.
- After task run: It calculates the next `runAt` with rrule when it is
provided.

This PR doesn't apply any change on `At task update` as it requires a
further investigation and consideration. We will handle it with a
follow-on issue.
You can use the test task `sampleRecurringTask` to test the feature.
Just create a task with rrule in the schedule config.
Then check the runAt field in the task SO to see if it is the expected
datetime.
Then run the task one more time and check the new `runAt`

I also used the usage reporting task in the actions plugin to test the
feature.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 0878a09)
@ersin-erdal ersin-erdal requested a review from kibanamachine as a code owner May 9, 2025 13:25
@ersin-erdal ersin-erdal added the backport This PR is a backport of another PR label May 9, 2025
@ersin-erdal ersin-erdal enabled auto-merge (squash) May 9, 2025 13:25
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #86 / machine learning - anomaly detection anomaly explorer with influencers with farequote based multi metric job Anomaly Charts as embeddable attaches an embeddable to a case

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
taskManager 66 69 +3

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
taskManager 9 10 +1
Unknown metric groups

API count

id before after diff
taskManager 113 116 +3

History

@ersin-erdal ersin-erdal merged commit aa17aeb into elastic:8.19 May 14, 2025
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants