-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
feat(slo): Create SLO with specified ID #157057
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
3eeb1be
to
6c82e52
Compare
Pinging @elastic/actionable-observability (Team: Actionable Observability) |
32c6732
to
3c3ac8c
Compare
@@ -103,7 +126,7 @@ describe('BurnRateRuleExecutor', () => { | |||
}); | |||
|
|||
it('throws when the slo is not found', async () => { | |||
soClientMock.get.mockRejectedValue(new Error('NotFound')); | |||
soClientMock.find.mockRejectedValue(new SLONotFound('SLO [inexistent] not found')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: non-existent
}); | ||
}); | ||
|
||
it('throws when the SLO id already exists and "throwOnConflict" is true', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice tests
@@ -66,36 +66,58 @@ export interface SLORepository { | |||
export class KibanaSavedObjectsSLORepository implements SLORepository { | |||
constructor(private soClient: SavedObjectsClientContract) {} | |||
|
|||
async save(slo: SLO): Promise<SLO> { | |||
async save(slo: SLO, options = { throwOnConflict: false }): Promise<SLO> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we set this to true
by default? I mean, most cases in this PR pass an explicit true
. I'm wondering in which case a consumer would not want it to throw on conflict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The edit flow saves with throwOnConflict set to false. So if we change the default, we need to explicitly set the false value in the edit flow.
I can change the default value, the create service will call save without options, while the edit service will call it with throwOnConflict: false
.
IMO, both ways work for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good; left some questions.
c64b55d
to
4d1d0bd
Compare
💚 Build Succeeded
Metrics [docs]Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @kdelemme |
Resolves #156425
📝 Summary
This PR allows the option to provide an slo id upon creation. The slo id must be between 8 and 36 characters.
When the id is not specified, we fallback on a uuidv1.
Since the slo id is not always a uuidv1, we cannot keep using the slo id as the related saved object ID. Therefore, the slo repository has been updated.
When creating an SLO with an ID already in use, we return a 409 Conflict.
🖼️ Screenshots
🥼 Testing
Create an SLO with a provided ID, the response should be a 200. Then, retry and the response should become 409.