[SLO] Check for unique SLO ids across spaces#214496
[SLO] Check for unique SLO ids across spaces#214496baileycash-elastic merged 16 commits intoelastic:mainfrom
Conversation
| type: SO_SLO_TYPE, | ||
| perPage: 0, | ||
| filter: `slo.attributes.id:(${id})`, | ||
| namespaces: [...namespaces], |
There was a problem hiding this comment.
this will only work to spaces which user have access to.
you need to use kibana internal user for this kinda use-case.
There was a problem hiding this comment.
Ah yes good catch - Sorry Bailey I forgot the soClient was user bound in this service
dmlemeshko
left a comment
There was a problem hiding this comment.
x-pack/test/api_integration/deployment_agnostic/services/slo_api.ts changes LGTM
f8a3c61 to
ccf84c2
Compare
| type: SO_SLO_TYPE, | ||
| perPage: 0, | ||
| filter: `slo.attributes.id:(${id})`, | ||
| namespaces: [...namespaces], |
There was a problem hiding this comment.
You can always specify namespaces: ["*"] because there is no other usage now, and remove the params from the function.
| } | ||
|
|
||
| private async assertSLOInexistant(slo: SLODefinition) { | ||
| const exists = await this.repository.exists(slo.id); |
There was a problem hiding this comment.
I know I'm the one who suggested a service for that but thinking it more thoroughly we could avoid the extra wiring, and just provide the internalSOClient to the CreateSLO application service, and this assertSLOInexistant would query the internalSOClient directly.
There was a problem hiding this comment.
The service was actually easier to implement because passing in the new internal client directly would have required updating the repository instances in all routes. Adding a new service was less of a breaking change.
| }); | ||
| }); | ||
|
|
||
| it('creates two SLOs with matching ids across different spaces', async () => { |
|
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]
History
|
kdelemme
left a comment
There was a problem hiding this comment.
LGTM! Thanks for making the changes
| const [coreStart] = await corePlugins.getStartServices(); | ||
| const internalSoClient = new SavedObjectsClient( | ||
| coreStart.savedObjects.createInternalRepository() | ||
| ); |
There was a problem hiding this comment.
one nice refactor you could do is move these common declarations like internalSOClinet to https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/slo/server/routes/register_routes.ts#L30
this it would become available in const sloContext = await context.slo;
and you could pass that context to each service, that way you won't have to declare stuff like this in each route where required.
|
Starting backport for target branches: 9.0 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary Resolves elastic#212784 Ensure that when an SLO is created, the id is verified across all spaces. ## Release Notes Ensure that when an SLO is created, the id is verified across all spaces. ## Testing 1. Create an SLO and save the id returned in the response in a space "A" 2. Create a second SLO with the id saved from the first SLO in the request in a different space "B" 3. User should receive a 409 error from the SLO API. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> (cherry picked from commit 56f1ebf) # Conflicts: # x-pack/solutions/observability/plugins/slo/server/routes/slo/create_slo.ts # x-pack/solutions/observability/plugins/slo/server/routes/slo/inspect_slo.ts # x-pack/solutions/observability/plugins/slo/server/services/create_slo.ts
## Summary Resolves elastic#212784 Ensure that when an SLO is created, the id is verified across all spaces. ## Release Notes Ensure that when an SLO is created, the id is verified across all spaces. ## Testing 1. Create an SLO and save the id returned in the response in a space "A" 2. Create a second SLO with the id saved from the first SLO in the request in a different space "B" 3. User should receive a 409 error from the SLO API. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
## Summary Resolves elastic#212784 Ensure that when an SLO is created, the id is verified across all spaces. ## Release Notes Ensure that when an SLO is created, the id is verified across all spaces. ## Testing 1. Create an SLO and save the id returned in the response in a space "A" 2. Create a second SLO with the id saved from the first SLO in the request in a different space "B" 3. User should receive a 409 error from the SLO API. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> (cherry picked from commit 56f1ebf) # Conflicts: # x-pack/solutions/observability/plugins/slo/server/routes/slo/create_slo.ts # x-pack/solutions/observability/plugins/slo/server/routes/slo/inspect_slo.ts # x-pack/solutions/observability/plugins/slo/server/services/create_slo.ts
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
# Backport This will backport the following commits from `main` to `9.0`: - [[SLO] Check for unique SLO ids across spaces (#214496)](#214496) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Bailey Cash","email":"bailey.cash@elastic.co"},"sourceCommit":{"committedDate":"2025-03-18T14:44:58Z","message":"[SLO] Check for unique SLO ids across spaces (#214496)\n\n## Summary \nResolves #212784 \nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Release Notes\nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Testing\n1. Create an SLO and save the id returned in the response in a space \"A\"\n2. Create a second SLO with the id saved from the first SLO in the\nrequest in a different space \"B\"\n3. User should receive a 409 error from the SLO API.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Security","backport missing","backport:prev-minor","Team:obs-ux-management","v9.1.0"],"title":"[SLO] Check for unique SLO ids across spaces","number":214496,"url":"https://github.com/elastic/kibana/pull/214496","mergeCommit":{"message":"[SLO] Check for unique SLO ids across spaces (#214496)\n\n## Summary \nResolves #212784 \nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Release Notes\nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Testing\n1. Create an SLO and save the id returned in the response in a space \"A\"\n2. Create a second SLO with the id saved from the first SLO in the\nrequest in a different space \"B\"\n3. User should receive a 409 error from the SLO API.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214496","number":214496,"mergeCommit":{"message":"[SLO] Check for unique SLO ids across spaces (#214496)\n\n## Summary \nResolves #212784 \nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Release Notes\nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Testing\n1. Create an SLO and save the id returned in the response in a space \"A\"\n2. Create a second SLO with the id saved from the first SLO in the\nrequest in a different space \"B\"\n3. User should receive a 409 error from the SLO API.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878"}}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary Resolves elastic#212784 Ensure that when an SLO is created, the id is verified across all spaces. ## Release Notes Ensure that when an SLO is created, the id is verified across all spaces. ## Testing 1. Create an SLO and save the id returned in the response in a space "A" 2. Create a second SLO with the id saved from the first SLO in the request in a different space "B" 3. User should receive a 409 error from the SLO API. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
## Summary Resolves elastic#212784 Ensure that when an SLO is created, the id is verified across all spaces. ## Release Notes Ensure that when an SLO is created, the id is verified across all spaces. ## Testing 1. Create an SLO and save the id returned in the response in a space "A" 2. Create a second SLO with the id saved from the first SLO in the request in a different space "B" 3. User should receive a 409 error from the SLO API. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…lastic#215379) # Backport This will backport the following commits from `main` to `9.0`: - [[SLO] Check for unique SLO ids across spaces (elastic#214496)](elastic#214496) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Bailey Cash","email":"bailey.cash@elastic.co"},"sourceCommit":{"committedDate":"2025-03-18T14:44:58Z","message":"[SLO] Check for unique SLO ids across spaces (elastic#214496)\n\n## Summary \nResolves elastic#212784 \nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Release Notes\nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Testing\n1. Create an SLO and save the id returned in the response in a space \"A\"\n2. Create a second SLO with the id saved from the first SLO in the\nrequest in a different space \"B\"\n3. User should receive a 409 error from the SLO API.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Security","backport missing","backport:prev-minor","Team:obs-ux-management","v9.1.0"],"title":"[SLO] Check for unique SLO ids across spaces","number":214496,"url":"https://github.com/elastic/kibana/pull/214496","mergeCommit":{"message":"[SLO] Check for unique SLO ids across spaces (elastic#214496)\n\n## Summary \nResolves elastic#212784 \nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Release Notes\nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Testing\n1. Create an SLO and save the id returned in the response in a space \"A\"\n2. Create a second SLO with the id saved from the first SLO in the\nrequest in a different space \"B\"\n3. User should receive a 409 error from the SLO API.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214496","number":214496,"mergeCommit":{"message":"[SLO] Check for unique SLO ids across spaces (elastic#214496)\n\n## Summary \nResolves elastic#212784 \nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Release Notes\nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Testing\n1. Create an SLO and save the id returned in the response in a space \"A\"\n2. Create a second SLO with the id saved from the first SLO in the\nrequest in a different space \"B\"\n3. User should receive a 409 error from the SLO API.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878"}}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 6fe8399) # Conflicts: # x-pack/solutions/observability/plugins/slo/server/routes/slo/create_slo.ts # x-pack/solutions/observability/plugins/slo/server/routes/slo/inspect_slo.ts
## Summary Resolves elastic#212784 Ensure that when an SLO is created, the id is verified across all spaces. ## Release Notes Ensure that when an SLO is created, the id is verified across all spaces. ## Testing 1. Create an SLO and save the id returned in the response in a space "A" 2. Create a second SLO with the id saved from the first SLO in the request in a different space "B" 3. User should receive a 409 error from the SLO API. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> (cherry picked from commit 56f1ebf) # Conflicts: # x-pack/solutions/observability/plugins/slo/server/routes/slo/create_slo.ts # x-pack/solutions/observability/plugins/slo/server/routes/slo/inspect_slo.ts # x-pack/solutions/observability/plugins/slo/server/services/create_slo.test.ts # x-pack/solutions/observability/plugins/slo/server/services/create_slo.ts
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
# Backport This will backport the following commits from `main` to `8.19`: - [[SLO] Check for unique SLO ids across spaces (#214496)](#214496) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Bailey Cash","email":"bailey.cash@elastic.co"},"sourceCommit":{"committedDate":"2025-03-18T14:44:58Z","message":"[SLO] Check for unique SLO ids across spaces (#214496)\n\n## Summary \nResolves #212784 \nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Release Notes\nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Testing\n1. Create an SLO and save the id returned in the response in a space \"A\"\n2. Create a second SLO with the id saved from the first SLO in the\nrequest in a different space \"B\"\n3. User should receive a 409 error from the SLO API.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Security","v9.0.0","backport:prev-minor","Team:obs-ux-management","v9.1.0"],"title":"[SLO] Check for unique SLO ids across spaces","number":214496,"url":"https://github.com/elastic/kibana/pull/214496","mergeCommit":{"message":"[SLO] Check for unique SLO ids across spaces (#214496)\n\n## Summary \nResolves #212784 \nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Release Notes\nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Testing\n1. Create an SLO and save the id returned in the response in a space \"A\"\n2. Create a second SLO with the id saved from the first SLO in the\nrequest in a different space \"B\"\n3. User should receive a 409 error from the SLO API.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/215379","number":215379,"state":"MERGED","mergeCommit":{"sha":"6fe83990788ecf41c2cf171c36ff4fa171ea1e33","message":"[9.0] [SLO] Check for unique SLO ids across spaces (#214496) (#215379)\n\n# Backport\n\nThis will backport the following commits from `main` to `9.0`:\n- [[SLO] Check for unique SLO ids across spaces\n(#214496)](https://github.com/elastic/kibana/pull/214496)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>"}},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214496","number":214496,"mergeCommit":{"message":"[SLO] Check for unique SLO ids across spaces (#214496)\n\n## Summary \nResolves #212784 \nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Release Notes\nEnsure that when an SLO is created, the id is verified across all\nspaces.\n\n## Testing\n1. Create an SLO and save the id returned in the response in a space \"A\"\n2. Create a second SLO with the id saved from the first SLO in the\nrequest in a different space \"B\"\n3. User should receive a 409 error from the SLO API.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878"}}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kevin Delemme <kevin.delemme@elastic.co>
Summary
Resolves #212784
Ensure that when an SLO is created, the id is verified across all spaces.
Release Notes
Ensure that when an SLO is created, the id is verified across all spaces.
Testing