From 02416736d0d1b9dafe04e3217cecb167636e6447 Mon Sep 17 00:00:00 2001 From: gotjosh Date: Thu, 10 Feb 2022 04:28:03 -0700 Subject: [PATCH] Ruler: Rule group not found API message (#5362) * 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 --- pkg/ruler/rulestore/objectclient/rule_store.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/ruler/rulestore/objectclient/rule_store.go b/pkg/ruler/rulestore/objectclient/rule_store.go index 747cf728f6cc..b945c298af0b 100644 --- a/pkg/ruler/rulestore/objectclient/rule_store.go +++ b/pkg/ruler/rulestore/objectclient/rule_store.go @@ -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()) } @@ -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