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

Ruler API and ObjectStore Backend #2269

Merged
merged 11 commits into from
Mar 20, 2020

Conversation

jtlisi
Copy link
Contributor

@jtlisi jtlisi commented Mar 12, 2020

API Changes

This PR adds an API to the ruler service based on this design document (https://docs.google.com/document/d/1gNKiC5L_zWQ4GGgtdhJJ6FnaZXyJJBvdGTUmF0wgEFg/edit?usp=sharing)

Object Storage Changes

  • It creates a generic storage client for rules based on our chunk.ObjectClient interface
  • The delimiter was made a configurable option for the object storage clients to make this possible. The delimiter is set at the construction of the object storage client

Integration Tests

  • A ruler integration test was added that ensures a rule group can be set, is running in a Prometheus manager, and can be deleted
  • A ruler address was added to the integration test cortex client

Which issue(s) this PR fixes:
Related #1547 #1244

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md

jtlisi added 4 commits March 12, 2020 12:54
Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
jtlisi added 4 commits March 12, 2020 16:03
Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
…c checks

Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Nice work.
I'd like to see changes to remove some code duplication in api.go, and unit test or two for escaping namespaces and groups in the request paths, to make sure it's not broken by accident in the future, but overall 👍

pkg/ruler/rules/store.go Show resolved Hide resolved
pkg/ruler/api.go Outdated Show resolved Hide resolved
pkg/ruler/api.go Outdated Show resolved Hide resolved
pkg/ruler/api.go Outdated Show resolved Hide resolved
pkg/ruler/api.go Outdated Show resolved Hide resolved
pkg/ruler/api.go Outdated Show resolved Hide resolved
pkg/ruler/api.go Outdated Show resolved Hide resolved
pkg/ruler/api.go Outdated Show resolved Hide resolved
pkg/ruler/api.go Show resolved Hide resolved
pkg/ruler/rules/objectclient/rule_store.go Show resolved Hide resolved
jtlisi and others added 2 commits March 18, 2020 12:10
Co-Authored-By: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
@jtlisi jtlisi force-pushed the 20191122_ruler_with_api branch from f0c09ba to 5d88330 Compare March 18, 2020 18:12
Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Nice improvements! There are few missing returns in methods, my other comments are mostly nitpicking.

pkg/ruler/api.go Outdated Show resolved Hide resolved
pkg/ruler/api.go Outdated Show resolved Hide resolved
pkg/ruler/api.go Show resolved Hide resolved
pkg/ruler/api.go Show resolved Hide resolved
pkg/ruler/api.go Show resolved Hide resolved
pkg/ruler/api.go Show resolved Hide resolved
pkg/ruler/api.go Show resolved Hide resolved
pkg/ruler/api.go Outdated Show resolved Hide resolved
"github.com/cortexproject/cortex/pkg/util"
)

// RegisterRoutes registers the ruler API HTTP routes with the provided Router.
func (r *Ruler) RegisterRoutes(router *mux.Router) {
func (r *Ruler) RegisterRoutes(router *mux.Router, middleware middleware.Interface) {
router = router.UseEncodedPath()
Copy link
Contributor

Choose a reason for hiding this comment

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

One possible way to test it would be to have muxVars global variable, that defaults to mux.Vars but could be set to your own function in tests.

@jtlisi
Copy link
Contributor Author

jtlisi commented Mar 19, 2020

One possible way to test it would be to have muxVars global variable, that defaults to mux.Vars but could be set to your own function in tests.

One way would be injecting them into the ctx of the request that is passed to the function. But I feel like it's more important to have integration tests for this behavior since the interplay with the gorilla router is so important.

Signed-off-by: Jacob Lisi <jacob.t.lisi@gmail.com>
Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my feedback!

@jtlisi jtlisi merged commit a32919e into cortexproject:master Mar 20, 2020
@jtlisi jtlisi deleted the 20191122_ruler_with_api branch July 21, 2020 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants