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

Alerting: Support deleting rule groups in the provisioning API #83514

Merged
merged 3 commits into from
Feb 28, 2024

Conversation

joeblubaugh
Copy link
Contributor

Adds support for DELETE to the provisioning API's alert rule groups route, which allows deleting the rule group with a single API call. Previously, groups were deleted by deleting rules one-by-one.

Fixes #81860

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

Adds support for DELETE to the provisioning API's alert rule groups route, which allows deleting the rule group with a
single API call. Previously, groups were deleted by deleting rules one-by-one.

Fixes #81860
@joeblubaugh joeblubaugh requested a review from a team as a code owner February 27, 2024 13:15
@joeblubaugh joeblubaugh requested review from rwwiv, JacobsonMT, yuri-tceretian and grobinson-grafana and removed request for a team February 27, 2024 13:15
@joeblubaugh joeblubaugh added area/alerting Grafana Alerting add to changelog no-backport Skip backport of PR labels Feb 27, 2024
@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.0.x milestone Feb 27, 2024
@joeblubaugh joeblubaugh changed the title Alerting: feat: support deleting rule groups in the provisioning API Alerting: support deleting rule groups in the provisioning API Feb 27, 2024
@joeblubaugh
Copy link
Contributor Author

Could someone please help me generate the updated swagger documentation for this branch? go-swagger is panicking on me and I can't seem to track the problem down.

(re)installing /Users/joe/go/bin/swagger-v0.30.2
go: downloading github.com/go-swagger/go-swagger v0.30.2
go: downloading github.com/go-openapi/runtime v0.24.1
go: downloading github.com/toqueteos/webbrowser v1.2.0
go: downloading golang.org/x/sys v0.0.0-20220829200755-d48e67d00261
go: downloading github.com/go-openapi/inflect v0.19.0
go: downloading golang.org/x/tools v0.1.12
go: downloading go.mongodb.org/mongo-driver v1.10.1
go: downloading github.com/go-openapi/jsonreference v0.20.0
go: downloading github.com/google/uuid v1.1.2
go: downloading golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90
go: downloading github.com/subosito/gotenv v1.3.0
go: downloading gopkg.in/ini.v1 v1.66.4
go: downloading github.com/pelletier/go-toml/v2 v2.0.1
go: downloading golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
SWAGGER_GENERATE_EXTENSION=false /Users/joe/go/bin/swagger-v0.30.2 generate spec -m -w definitions -o spec.json && SWAGGER_GENERATE_EXTENSION=false /Users/joe/go/bin/swagger-v0.30.2 generate spec -m --include-tag=stable -o spec-stable.json
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1029b1dd0]

goroutine 30 [running]:
go/types.(*Checker).handleBailout(0x140004c6200, 0x14000dd3c38)
        /opt/homebrew/Cellar/go/1.22.0/libexec/src/go/types/check.go:367 +0x9c
panic({0x102e7dce0?, 0x1034e0ef0?})
        /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x102f6d3f8, 0x1034ebd40})
        /opt/homebrew/Cellar/go/1.22.0/libexec/src/go/types/sizes.go:228 +0x320
go/types.(*Config).sizeof(...)

@joeblubaugh joeblubaugh changed the title Alerting: support deleting rule groups in the provisioning API Alerting: Support deleting rule groups in the provisioning API Feb 27, 2024
@joeblubaugh joeblubaugh requested a review from a team as a code owner February 27, 2024 22:10
@joeblubaugh joeblubaugh requested review from zserge, mildwonkey and undef1nd and removed request for a team February 27, 2024 22:10
Copy link
Contributor

@yuri-tceretian yuri-tceretian left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@rwwiv rwwiv left a comment

Choose a reason for hiding this comment

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

LGTM, there's a test failure due to path count but looks like the all the added tests are succeeding.

@@ -40,7 +40,7 @@ func TestAuthorize(t *testing.T) {
}
paths[p] = methods
}
require.Len(t, paths, 64)
require.Len(t, paths, 65)
Copy link
Contributor

@rwwiv rwwiv Feb 27, 2024

Choose a reason for hiding this comment

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

Test is failing when this was bumped, looks like we don't count all methods?

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 output looks like this:
/ruler/grafana/api/v1/rules/{Namespace}:[GET POST DELETE] /ruler/grafana/api/v1/rules/{Namespace}/export:[POST] /ruler/grafana/api/v1/rules/{Namespace}/{Groupname}:[GET DELETE], and this change only adds a new method, not a new path. I wouldn't expect this number to increase for this change.

This change doesn't add any new paths to the API, only new methods.
@joeblubaugh
Copy link
Contributor Author

Tests are looking green. @yuri-tceretian could you merge when you're available?

@yuri-tceretian yuri-tceretian merged commit b905777 into main Feb 28, 2024
12 checks passed
@yuri-tceretian yuri-tceretian deleted the joeb/81860/delete-rulegroup branch February 28, 2024 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Provisioning API: Support deleting a rule group
4 participants