Add rrule schema to task schedule with intermediate release#219429
Add rrule schema to task schedule with intermediate release#219429ersin-erdal merged 23 commits intoelastic:mainfrom
Conversation
… src/core/server/integration_tests/ci_checks'
|
Pinging @elastic/response-ops (Team:ResponseOps) |
|
|
||
| const rruleCommon = schema.object({ | ||
| freq: schema.number(), | ||
| interval: schema.number(), |
There was a problem hiding this comment.
should we set a minimum here?
| const byminute = schema.maybe(schema.arrayOf(schema.number({ min: 0, max: 59 }))); | ||
| const byhour = schema.maybe(schema.arrayOf(schema.number({ min: 0, max: 23 }))); | ||
| const byweekday = schema.maybe(schema.arrayOf(schema.number({ min: 1, max: 7 }))); | ||
| const bymonthday = schema.maybe(schema.arrayOf(schema.number({ min: 1, max: 31 }))); |
There was a problem hiding this comment.
The alerting schema has some validations for these fields (checking for non-empty arrays). Should we add similar validations here? Also, I know we're only supporting a subset of the rRule specification, but should we try to make it as close to the alerting one as possible? For example, here, byweekday is a number that maps to an enum but in the alerting spec, it's a string.
Alerting schema: x-pack/platform/plugins/shared/alerting/common/routes/r_rule/request/schemas/v1.ts
There was a problem hiding this comment.
I added the min length check but byweekday is interesting as it can take both string and number.
here: x-pack/platform/plugins/shared/alerting/server/saved_objects/schemas/raw_rule/v3.ts
validation in the request schema you shared also accepts numbers between 1-4 in the regex but as string!
Should we stick with it??
There was a problem hiding this comment.
Btw idk why it is only between 1 and 4! maybe someone confused it with freq since it takes 4 numbers...
There was a problem hiding this comment.
OK i modified it to cover the both cases: numbers between 1-7 and enums MO, TH etc...
Looks like our rrule lib supports both.
There was a problem hiding this comment.
cc @cnasikas Any feedback/comments on this schema?
There was a problem hiding this comment.
I would advise following the schema as defined in x-pack/platform/plugins/shared/alerting/common/routes/r_rule/request/schemas/v1.ts as closely as possible. The byweekday can be a specific date like MO or -1WE, which can mean the last Wednesday of the month. In the UI this is configured like:
The rrule library can automatically handle this kind of input.
There was a problem hiding this comment.
It would be nice if we had a schema in a package where you could import it (future work).
There was a problem hiding this comment.
OK, I used the same schemas.
jloleysens
left a comment
There was a problem hiding this comment.
Overall looks good! However, I don't think we've quite concluded a related conversation. Would be good to do so before merging.
…ersin-erdal/kibana into 216308-add-rrule-to-task-model-versions
… src/core/server/integration_tests/ci_checks'
| "interval": { | ||
| "type": "keyword" | ||
| }, | ||
| "rrule": { |
There was a problem hiding this comment.
probably don't need it at all, unless we're doing an exists query in the code somewhere currently?
… src/core/server/integration_tests/ci_checks'
| bymonthday: schema.never(), | ||
| }); | ||
|
|
||
| export const rruleSchedule = schema.oneOf([rruleMonthly, rruleWeekly, rruleDaily]); |
There was a problem hiding this comment.
What about having one schema and do feq: schema.oneOf[schema.literal(Frequency.DAILY), schema.literal(Frequency.WEEKLY), schema.literal(Frequency.MONTHLY].
There was a problem hiding this comment.
I grouped them because some configurations should not be used with some frequency types, it looks the same for now but when we add hourly and minutely we will not allow byweekday and byhour together as they break the library.
…ersin-erdal/kibana into 216308-add-rrule-to-task-model-versions
jloleysens
left a comment
There was a problem hiding this comment.
Mappings changes LGTM, did not know you could add dynamic: false after creation like this, TIL
…ersin-erdal/kibana into 216308-add-rrule-to-task-model-versions
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
… src/core/server/integration_tests/ci_checks'
|
@ersin-erdal I have your branch pulled into my scheduled report branch and am reusing these schemas for the scheduled report SO, I'm getting this type error for the rrule definition when it looks like this:
which is confusing because |
|
it works when i change it to |
The only difference between the schemas here and in my other PR is I am adding |
…ersin-erdal/kibana into 216308-add-rrule-to-task-model-versions
|
I'm deriving the type from the schema using TypeOf...maybe there's a better way of doing that? |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
|
|
Starting backport for target branches: 8.19, 9.0 https://github.com/elastic/kibana/actions/runs/14796596120 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…219429) Towards: elastic#216308 This PR adds the `rrule` schema to the task SO with an intermediate release for the following PR: elastic#217728 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 65cc416) # Conflicts: # src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts
…219429) (#219993) # Backport This will backport the following commits from `main` to `8.19`: - [Add rrule schema to task schedule with intermediate release (#219429)](#219429) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ersin Erdal","email":"92688503+ersin-erdal@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-05-02T13:54:00Z","message":"Add rrule schema to task schedule with intermediate release (#219429)\n\nTowards: #216308\n\nThis PR adds the `rrule` schema to the task SO with an intermediate\nrelease for the following PR:\n#217728\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"65cc4167b57008f5b3577be4476f0932c5c8d278","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","backport:version","v9.1.0","v8.19.0"],"title":"Add rrule schema to task schedule with intermediate release","number":219429,"url":"https://github.com/elastic/kibana/pull/219429","mergeCommit":{"message":"Add rrule schema to task schedule with intermediate release (#219429)\n\nTowards: #216308\n\nThis PR adds the `rrule` schema to the task SO with an intermediate\nrelease for the following PR:\n#217728\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"65cc4167b57008f5b3577be4476f0932c5c8d278"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219429","number":219429,"mergeCommit":{"message":"Add rrule schema to task schedule with intermediate release (#219429)\n\nTowards: #216308\n\nThis PR adds the `rrule` schema to the task SO with an intermediate\nrelease for the following PR:\n#217728\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"65cc4167b57008f5b3577be4476f0932c5c8d278"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…219429) Towards: elastic#216308 This PR adds the `rrule` schema to the task SO with an intermediate release for the following PR: elastic#217728 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…219429) Towards: elastic#216308 This PR adds the `rrule` schema to the task SO with an intermediate release for the following PR: elastic#217728 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Towards: #216308
This PR adds the
rruleschema to the task SO with an intermediate release for the following PR:#217728