Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OAS] Support setting availability #196647

Merged
merged 11 commits into from
Oct 21, 2024
Merged

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Oct 17, 2024

Summary

Close #181995

Related #195325

Enables API authors to set APIs overall availability to one of:

experimental: the "loosest" commitment to a public API, may be removed
beta: expect changes, but the intention is to reach stable
stable: rock soild 🪨 , ain't going nowhere and safe to integrate with and expect long term support with a deprecation window of 18 months

Note: at time of writing we still need to figure out what experimental and beta practically mean for APIs, but could enable a bit more iteration without versioning and maintenance overhead.

Checklist

@jloleysens jloleysens added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc release_note:skip Skip the PR/issue when compiling release notes v9.0.0 Feature:OAS Work or issues related to Core-provided mechanisms for generating OAS v8.16.0 backport:version Backport to applied version labels labels Oct 17, 2024
@jloleysens jloleysens self-assigned this Oct 17, 2024
@jloleysens
Copy link
Contributor Author

/ci

Comment on lines +169 to +181
export function setXState(
availability: RouteConfigOptions<RouteMethod>['availability'],
operation: CustomOperationObject
): void {
if (availability) {
if (availability.stability === 'experimental') {
operation['x-state'] = 'Technical Preview';
}
if (availability.stability === 'beta') {
operation['x-state'] = 'Beta';
}
}
}
Copy link
Contributor Author

@jloleysens jloleysens Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the logic for adding x-state, added the types for since but we can implement it in another PR.

@jloleysens
Copy link
Contributor Author

/ci

@lcawl
Copy link
Contributor

lcawl commented Oct 17, 2024

I added this new availability clause to a couple of endpoints and regenerated the OpenAPI document and it looks great! The only thing I can't tell from this PR is how/if I could indicate that an endpoint has differing availability in serverless context, for example. In the elasticsearch specification they have this flavour-awareness per https://github.com/elastic/elasticsearch-specification/blob/main/docs/add-new-api.md#add-the-endpoint-request-definition. Is this something that's possible and desirable here too?

* @remark intended to be used for informational purposes only.
*
*/
availability?: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ES specification has availability as either stack or serverless and we're missing that in the route config options.
It's probably not a deal breaker now but would be great to surface in the generated spec.

Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good thus far. I left a question about choosing stability default that I'd like to hear your thoughts on. The main concern is consistency and risk.

*
*/
availability?: {
/** @default stable */
Copy link
Contributor

@TinaHeiligers TinaHeiligers Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Route access defaults to 'internal'. WDYT about reflecting that here and setting the default stability as 'experimental'? That way there's less risk to adding new routes and forgetting to change the stability descriptor to 'experimental' pre-GA.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I considered this too, but then realised our existing public routes would default to "experimental" too unless we explicitly set them all to "stable". So, in practice, we default to "stable" already today.

I'm not opposed to changing the default, and I tend to agree with you starting as "experimental" is better I just wanted to avoid a wider effort. We could do it as follow up work, happy to open an issue.

I wasn't too concerned about internal routes bc they are in principle "not available", but I think we can capture that in the doc comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I considered this too, but then realised our existing public routes would default to "experimental" too unless we explicitly set them all to "stable".

We don't have that many public routes as we do internal. From a cost/benefit pov, changing public routes to stable is worth the effort of mitigating the risk of accidentally marking a route as stable when it's not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not opposed to changing the default, and I tend to agree with you starting as "experimental" is better I just wanted to avoid a wider effort. We could do it as follow up work, happy to open an issue.

Sounds good, LMK when you've created an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#197003 🙌🏻

packages/core/http/core-http-server/src/router/route.ts Outdated Show resolved Hide resolved
@jloleysens
Copy link
Contributor Author

jloleysens commented Oct 18, 2024

@TinaHeiligers @lcawl re "flavour" availability would this not already be captured by the fact that we have a kibana.yaml and kibana.serverless.yaml bundle for each flavour? Teams can dynamically register routes per offering.

Let me know what you think!

@jloleysens jloleysens marked this pull request as ready for review October 18, 2024 09:14
@jloleysens jloleysens requested a review from a team as a code owner October 18, 2024 09:14
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@TinaHeiligers
Copy link
Contributor

TinaHeiligers commented Oct 18, 2024

re "flavour" availability would this not already be captured by the fact that we have a kibana.yaml and kibana.serverless.yaml bundle for each flavour?

It would if we release separate specs for each. So far, I've only seen the OpenApi specs for stack. Where do we publish those for Serverless?
nm, I found them in our internal docs.

Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unblocking to add x-state with the understanding that we'll switch the default stability to experimental in a follow up PR.

*
*/
availability?: {
/** @default stable */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not opposed to changing the default, and I tend to agree with you starting as "experimental" is better I just wanted to avoid a wider effort. We could do it as follow up work, happy to open an issue.

Sounds good, LMK when you've created an issue.

@jloleysens jloleysens enabled auto-merge (squash) October 21, 2024 08:35
@jloleysens jloleysens merged commit 608cc70 into elastic:main Oct 21, 2024
23 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.16

https://github.com/elastic/kibana/actions/runs/11438246013

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #53 / Rule execution logic API Detection Engine - Execution logic @ess @serverless New terms type rules, alert suppression should NOT suppress and update an alert if the alert is closed

Metrics [docs]

Unknown metric groups

API count

id before after diff
@kbn/core-http-server 532 533 +1

History

cc @jloleysens

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 21, 2024
## Summary

Close elastic#181995

Related elastic#195325

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Christiane (Tina) Heiligers <[email protected]>
(cherry picked from commit 608cc70)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.16

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 21, 2024
# Backport

This will backport the following commits from `main` to `8.16`:
- [[OAS] Support setting availability
(#196647)](#196647)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jean-Louis
Leysens","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-21T10:30:45Z","message":"[OAS]
Support setting availability (#196647)\n\n## Summary\r\n\r\nClose
https://github.com/elastic/kibana/issues/181995\r\n\r\nRelated
https://github.com/elastic/kibana/pull/195325\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Christiane (Tina)
Heiligers
<[email protected]>","sha":"608cc70be56fa63cb68a93d480e545fa95c0846a","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","v9.0.0","Feature:OAS","v8.16.0","backport:version"],"title":"[OAS]
Support setting
availability","number":196647,"url":"https://github.com/elastic/kibana/pull/196647","mergeCommit":{"message":"[OAS]
Support setting availability (#196647)\n\n## Summary\r\n\r\nClose
https://github.com/elastic/kibana/issues/181995\r\n\r\nRelated
https://github.com/elastic/kibana/pull/195325\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Christiane (Tina)
Heiligers
<[email protected]>","sha":"608cc70be56fa63cb68a93d480e545fa95c0846a"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196647","number":196647,"mergeCommit":{"message":"[OAS]
Support setting availability (#196647)\n\n## Summary\r\n\r\nClose
https://github.com/elastic/kibana/issues/181995\r\n\r\nRelated
https://github.com/elastic/kibana/pull/195325\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Christiane (Tina)
Heiligers
<[email protected]>","sha":"608cc70be56fa63cb68a93d480e545fa95c0846a"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Jean-Louis Leysens <[email protected]>
@jbudz
Copy link
Member

jbudz commented Oct 22, 2024

@jloleysens there's a version gap with this backport. Can you check if this should also be backported to 8.x/8.17?

@jloleysens
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

jloleysens added a commit to jloleysens/kibana that referenced this pull request Oct 23, 2024
## Summary

Close elastic#181995

Related elastic#195325

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Christiane (Tina) Heiligers <[email protected]>
(cherry picked from commit 608cc70)
jloleysens added a commit that referenced this pull request Oct 23, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [[OAS] Support setting availability
(#196647)](#196647)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jean-Louis
Leysens","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-21T10:30:45Z","message":"[OAS]
Support setting availability (#196647)\n\n## Summary\r\n\r\nClose
https://github.com/elastic/kibana/issues/181995\r\n\r\nRelated
https://github.com/elastic/kibana/pull/195325\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Christiane (Tina)
Heiligers
<[email protected]>","sha":"608cc70be56fa63cb68a93d480e545fa95c0846a","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","v9.0.0","Feature:OAS","v8.16.0","backport:version","v8.17.0"],"number":196647,"url":"https://github.com/elastic/kibana/pull/196647","mergeCommit":{"message":"[OAS]
Support setting availability (#196647)\n\n## Summary\r\n\r\nClose
https://github.com/elastic/kibana/issues/181995\r\n\r\nRelated
https://github.com/elastic/kibana/pull/195325\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Christiane (Tina)
Heiligers
<[email protected]>","sha":"608cc70be56fa63cb68a93d480e545fa95c0846a"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196647","number":196647,"mergeCommit":{"message":"[OAS]
Support setting availability (#196647)\n\n## Summary\r\n\r\nClose
https://github.com/elastic/kibana/issues/181995\r\n\r\nRelated
https://github.com/elastic/kibana/pull/195325\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Christiane (Tina)
Heiligers
<[email protected]>","sha":"608cc70be56fa63cb68a93d480e545fa95c0846a"}},{"branch":"8.16","label":"v8.16.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/197025","number":197025,"state":"MERGED","mergeCommit":{"sha":"76993eb1f6b160a9f58377fee967c3b578023f5b","message":"[8.16]
[OAS] Support setting availability (#196647) (#197025)\n\n#
Backport\n\nThis will backport the following commits from `main` to
`8.16`:\n- [[OAS] Support setting
availability\n(#196647)](https://github.com/elastic/kibana/pull/196647)\n\n<!---
Backport version: 9.4.3 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Jean-Louis\nLeysens\",\"email\":\"[email protected]\"},\"sourceCommit\":{\"committedDate\":\"2024-10-21T10:30:45Z\",\"message\":\"[OAS]\nSupport
setting availability (#196647)\\n\\n##
Summary\\r\\n\\r\\nClose\nhttps://github.com//issues/181995\\r\\n\\r\\nRelated\nhttps://github.com//pull/195325\\r\\n\\r\\n\\r\\n###\nChecklist\\r\\n\\r\\n-
[x] [Unit
or\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most
common\nscenarios\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by:
Christiane
(Tina)\nHeiligers\n<[email protected]>\",\"sha\":\"608cc70be56fa63cb68a93d480e545fa95c0846a\",\"branchLabelMapping\":{\"^v9.0.0$\":\"main\",\"^v8.17.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"Team:Core\",\"release_note:skip\",\"v9.0.0\",\"Feature:OAS\",\"v8.16.0\",\"backport:version\"],\"title\":\"[OAS]\nSupport
setting\navailability\",\"number\":196647,\"url\":\"https://github.com/elastic/kibana/pull/196647\",\"mergeCommit\":{\"message\":\"[OAS]\nSupport
setting availability (#196647)\\n\\n##
Summary\\r\\n\\r\\nClose\nhttps://github.com//issues/181995\\r\\n\\r\\nRelated\nhttps://github.com//pull/195325\\r\\n\\r\\n\\r\\n###\nChecklist\\r\\n\\r\\n-
[x] [Unit
or\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most
common\nscenarios\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by:
Christiane
(Tina)\nHeiligers\n<[email protected]>\",\"sha\":\"608cc70be56fa63cb68a93d480e545fa95c0846a\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[\"8.16\"],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v9.0.0\",\"branchLabelMappingKey\":\"^v9.0.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/196647\",\"number\":196647,\"mergeCommit\":{\"message\":\"[OAS]\nSupport
setting availability (#196647)\\n\\n##
Summary\\r\\n\\r\\nClose\nhttps://github.com//issues/181995\\r\\n\\r\\nRelated\nhttps://github.com//pull/195325\\r\\n\\r\\n\\r\\n###\nChecklist\\r\\n\\r\\n-
[x] [Unit
or\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most
common\nscenarios\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by:
Christiane
(Tina)\nHeiligers\n<[email protected]>\",\"sha\":\"608cc70be56fa63cb68a93d480e545fa95c0846a\"}},{\"branch\":\"8.16\",\"label\":\"v8.16.0\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"}]}]\nBACKPORT-->\n\nCo-authored-by:
Jean-Louis Leysens
<[email protected]>"}},{"branch":"8.x","label":"v8.17.0","labelRegex":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels Feature:OAS Work or issues related to Core-provided mechanisms for generating OAS release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.16.0 v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support experimental APIs
6 participants