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

api/v2: Delete silence respond with 404 when silence is not found #3352

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/v2/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@ func (api *API) deleteSilenceHandler(params silence_ops.DeleteSilenceParams) mid
sid := params.SilenceID.String()
if err := api.silences.Expire(sid); err != nil {
level.Error(logger).Log("msg", "Failed to expire silence", "err", err)
if err == silence.ErrNotFound {
return silence_ops.NewDeleteSilenceNotFound()
}
return silence_ops.NewDeleteSilenceInternalServerError().WithPayload(err.Error())
}
return silence_ops.NewDeleteSilenceOK()
Expand Down
2 changes: 1 addition & 1 deletion api/v2/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func TestDeleteSilenceHandler(t *testing.T) {
}{
{
"unknownSid",
500,
404,
},
{
unexpiredSid,
Expand Down
57 changes: 57 additions & 0 deletions api/v2/client/silence/delete_silence_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ paths:
responses:
'200':
description: Delete silence response
'404':
description: A silence with the specified ID was not found
'500':
$ref: '#/responses/InternalServerError'
/alerts:
Expand Down
6 changes: 6 additions & 0 deletions api/v2/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions api/v2/restapi/operations/silence/delete_silence_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.