Skip to content

Commit

Permalink
Ruler: Rule group not found API message (#5362)
Browse files Browse the repository at this point in the history
* Ruler: Rule group not found API message

We copied over the ruler code as part of #5089, and it seems that at the same time we stopped depending on the object storage implementation of Cortex. Turns out, there are (slight) differences between the clients which meant that response returned by the API when we try to get a rule group that is not found had changed.

This ensures that is consistent with the error assertion that we have in the code for the ruler.

* Use the method from the interfaace to determine object storage

* also include DeleteObject

* appease the linter
  • Loading branch information
gotjosh authored Feb 10, 2022
1 parent 7fafe94 commit 0241673
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/ruler/rulestore/objectclient/rule_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewRuleStore(client chunk.ObjectClient, loadConcurrency int, logger log.Log
func (o *RuleStore) getRuleGroup(ctx context.Context, objectKey string, rg *rulespb.RuleGroupDesc) (*rulespb.RuleGroupDesc, error) {
reader, _, err := o.client.GetObject(ctx, objectKey)
if err != nil {
if err.Error() == chunk.ErrStorageObjectNotFound.Error() {
if o.client.IsObjectNotFoundErr(err) {
level.Debug(o.logger).Log("msg", "rule group does not exist", "name", objectKey)
return nil, errors.Wrapf(rulestore.ErrGroupNotFound, "get rule group user=%q, namespace=%q, name=%q", rg.GetUser(), rg.GetNamespace(), rg.GetName())
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func (o *RuleStore) SetRuleGroup(ctx context.Context, userID string, namespace s
func (o *RuleStore) DeleteRuleGroup(ctx context.Context, userID string, namespace string, groupName string) error {
objectKey := generateRuleObjectKey(userID, namespace, groupName)
err := o.client.DeleteObject(ctx, objectKey)
if err == chunk.ErrStorageObjectNotFound {
if o.client.IsObjectNotFoundErr(err) {
return rulestore.ErrGroupNotFound
}
return err
Expand Down

0 comments on commit 0241673

Please sign in to comment.