-
Notifications
You must be signed in to change notification settings - Fork 65
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
Enforce Labels on Returned Rules #191
Conversation
Rules are either Recording Rules or Alerting Rules, but not both. This commit fixes this fact in the OpenAPI specification. Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
16b16c7
to
589c6d7
Compare
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.
cool, thanks for catching that!
left one question/suggestion
f100a51
to
d4e5f41
Compare
Currently, when a group of rules is unmarshaled, the concrete type in Go will never be a rules.RecordingRule or a rules.AlertingRule, although those types are defined in the rules package. Instead those rules will always be some map[string]interface{} type. This means that it's not possible for users of the package to perform type assertions on the rules that are fetched via the client, which is a serious annoyance for anyone using the package. This commit fixes this by providing a custom unmarshaling function. Furthermore, in order to fix unmarshaling via both JSON and YAML, the commit switches the YAML package to ghodss/yaml, which is a superset of the current YAML package, go-yaml/yaml. Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
d4e5f41
to
d6fd21b
Compare
Currently, recording and alerting rules that are fetched from the new rules/raw API will not have any tenant label attached to them. This means that when the rules are configured on a Thanos Ruler, the time series that are generated will not have a tenant label on them. This is a big problem, because without this tenant label, the very tenant to whom the rules belong cannot query for the time series, making them in effect useless. This commit enforces that all rules returned by the rules/raw endpoint have a tenant_id label attached to them. Note: this is a distinct problem from ensuring that the rules written by a tenant are guaranteed to only include data from that tenant. Currently, the rules from a tenant can select data from any tenant. This is a distinct problem and should absolutely be tackled in a follow up. Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
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.
awesome 🎉
I've created a ticket for the note you mentioned in the description of the PR, so we don't forget about it: https://issues.redhat.com/browse/MON-2063
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 👍
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.
LGTM, Thanks!!
* rules/spec.yaml: fix enum Rules are either Recording Rules or Alerting Rules, but not both. This commit fixes this fact in the OpenAPI specification. Signed-off-by: Lucas Servén Marín <lserven@gmail.com> * rules: add custom UnmarshalJSON function Currently, when a group of rules is unmarshaled, the concrete type in Go will never be a rules.RecordingRule or a rules.AlertingRule, although those types are defined in the rules package. Instead those rules will always be some map[string]interface{} type. This means that it's not possible for users of the package to perform type assertions on the rules that are fetched via the client, which is a serious annoyance for anyone using the package. This commit fixes this by providing a custom unmarshaling function. Furthermore, in order to fix unmarshaling via both JSON and YAML, the commit switches the YAML package to ghodss/yaml, which is a superset of the current YAML package, go-yaml/yaml. Signed-off-by: Lucas Servén Marín <lserven@gmail.com> * rules/rules.go: regenerate Signed-off-by: Lucas Servén Marín <lserven@gmail.com> * api: enforce tenant on generated time series Currently, recording and alerting rules that are fetched from the new rules/raw API will not have any tenant label attached to them. This means that when the rules are configured on a Thanos Ruler, the time series that are generated will not have a tenant label on them. This is a big problem, because without this tenant label, the very tenant to whom the rules belong cannot query for the time series, making them in effect useless. This commit enforces that all rules returned by the rules/raw endpoint have a tenant_id label attached to them. Note: this is a distinct problem from ensuring that the rules written by a tenant are guaranteed to only include data from that tenant. Currently, the rules from a tenant can select data from any tenant. This is a distinct problem and should absolutely be tackled in a follow up. Signed-off-by: Lucas Servén Marín <lserven@gmail.com> Start e2e test Signed-off-by: Jéssica Lins <jessicaalins@gmail.com>
Currently, recording and alerting rules that are fetched from the new
rules/raw API will not have any tenant label attached to them. This
means that when the rules are configured on a Thanos Ruler, the time
series that are generated will not have a tenant label on them. This is
a big problem, because without this tenant label, the very tenant to
whom the rules belong cannot query for the time series, making them in
effect useless. This PR enforces that all rules returned by the
rules/raw endpoint have a tenant_id label attached to them.
Note: this is a distinct problem from ensuring that the rules written by
a tenant are guaranteed to only include data from that tenant.
Currently, the rules from a tenant can select data from any tenant. This
is a distinct problem and should absolutely be tackled in a follow up.
In order to be able to apply the labels, we must assert the type of the rules.
Currently, when a group of rules is unmarshaled, the concrete type in Go
will never be a rules.RecordingRule or a rules.AlertingRule, although
those types are defined in the rules package. Instead those rules will
always be some map[string]interface{} type. This means that it's not
possible for users of the package to perform type assertions on the
rules that are fetched via the client, which is a serious annoyance for
anyone using the package.
This PR also fixes this by providing a custom unmarshaling function.
Furthermore, in order to fix unmarshaling via both JSON and YAML, the
PR switches the YAML package to ghodss/yaml, which is a superset of
the current YAML package, go-yaml/yaml.
Finally, rules are either Recording Rules or Alerting Rules, but not both. This
PR fixes this fact in the OpenAPI specification.