Skip to content

Conversation

@baileycash-elastic
Copy link
Contributor

@baileycash-elastic baileycash-elastic commented Mar 13, 2025

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

  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.

@baileycash-elastic baileycash-elastic marked this pull request as ready for review March 14, 2025 13:56
@baileycash-elastic baileycash-elastic requested review from a team as code owners March 14, 2025 13:56
@baileycash-elastic baileycash-elastic added backport:prev-minor Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. Team:Security Platform Security: Auth, Users, Roles, Spaces, Audit Logging, etc t// release_note:fix labels Mar 14, 2025
@baileycash-elastic baileycash-elastic changed the title Slo 212784 [SLO] Check for unique SLO ids across spaces Mar 14, 2025
type: SO_SLO_TYPE,
perPage: 0,
filter: `slo.attributes.id:(${id})`,
namespaces: [...namespaces],
Copy link
Contributor

Choose a reason for hiding this comment

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

this will only work to spaces which user have access to.
you need to use kibana internal user for this kinda use-case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes good catch - Sorry Bailey I forgot the soClient was user bound in this service

Copy link
Member

@dmlemeshko dmlemeshko left a comment

Choose a reason for hiding this comment

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

x-pack/test/api_integration/deployment_agnostic/services/slo_api.ts changes LGTM

@dmlemeshko dmlemeshko self-requested a review March 14, 2025 15:27
type: SO_SLO_TYPE,
perPage: 0,
filter: `slo.attributes.id:(${id})`,
namespaces: [...namespaces],
Copy link
Contributor

Choose a reason for hiding this comment

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

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻 Nice!

@baileycash-elastic
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for making the changes

Comment on lines +43 to +46
const [coreStart] = await corePlugins.getStartServices();
const internalSoClient = new SavedObjectsClient(
coreStart.savedObjects.createInternalRepository()
);
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

@baileycash-elastic baileycash-elastic merged commit 56f1ebf into elastic:main Mar 18, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
9.0 Backport failed because of merge conflicts

You might need to backport the following PRs to 9.0:
- chore(slo): factorize error handler (#209671)

Manual backport

To create the backport manually run:

node scripts/backport --pr 214496

Questions ?

Please refer to the Backport tool documentation

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 20, 2025
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 214496 locally

@baileycash-elastic
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.0

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

Questions ?

Please refer to the Backport tool documentation

baileycash-elastic added a commit to baileycash-elastic/kibana that referenced this pull request Mar 20, 2025
## 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 <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
(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
clintandrewhall pushed a commit to clintandrewhall/kibana that referenced this pull request Mar 20, 2025
## 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 <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
baileycash-elastic added a commit to baileycash-elastic/kibana that referenced this pull request Mar 21, 2025
## 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 <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
(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
@baileycash-elastic
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.0

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

Questions ?

Please refer to the Backport tool documentation

@kibanamachine
Copy link
Contributor

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.

baileycash-elastic added a commit that referenced this pull request Mar 21, 2025
# 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":"[email protected]"},"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
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","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
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","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
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <[email protected]>
@kibanamachine kibanamachine added v9.0.0 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Mar 21, 2025
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Mar 22, 2025
## 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 <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
cqliu1 pushed a commit to cqliu1/kibana that referenced this pull request Mar 31, 2025
## 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 <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
baileycash-elastic added a commit to baileycash-elastic/kibana that referenced this pull request Apr 14, 2025
…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":"[email protected]"},"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
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","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
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","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
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <[email protected]>
(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
baileycash-elastic added a commit to baileycash-elastic/kibana that referenced this pull request May 6, 2025
## 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 <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
(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
@baileycash-elastic
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

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

Questions ?

Please refer to the Backport tool documentation

baileycash-elastic added a commit that referenced this pull request May 7, 2025
# 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":"[email protected]"},"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
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","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
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","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
<[email protected]>"}},{"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
<[email protected]>\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"56f1ebfca6300b1da68cf6fa721f450077aa1878"}}]}]
BACKPORT-->

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Kevin Delemme <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:fix Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. Team:Security Platform Security: Auth, Users, Roles, Spaces, Audit Logging, etc t// v8.19.0 v9.0.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SLO] Ensure ID uniqueness across all spaces

7 participants