(ctx context.Context)
| 836 | } |
| 837 | |
| 838 | func (r *Ruler) loadRuleGroups(ctx context.Context) (map[string]rulespb.RuleGroupList, map[string]rulespb.RuleGroupList, error) { |
| 839 | timer := prometheus.NewTimer(nil) |
| 840 | |
| 841 | defer func() { |
| 842 | storeLoadSeconds := timer.ObserveDuration().Seconds() |
| 843 | r.ruleGroupStoreLoadDuration.Set(storeLoadSeconds) |
| 844 | }() |
| 845 | |
| 846 | ownedConfigs, backupConfigs, err := r.listRules(ctx) |
| 847 | if err != nil { |
| 848 | level.Error(r.logger).Log("msg", "unable to list rules", "err", err) |
| 849 | return nil, nil, err |
| 850 | } |
| 851 | |
| 852 | loadedOwnedConfigs, err := r.store.LoadRuleGroups(ctx, ownedConfigs) |
| 853 | if err != nil { |
| 854 | level.Warn(r.logger).Log("msg", "failed to load some rules owned by this ruler", "count", len(ownedConfigs)-len(loadedOwnedConfigs), "err", err) |
| 855 | } |
| 856 | if r.cfg.RulesBackupEnabled() { |
| 857 | loadedBackupConfigs, err := r.store.LoadRuleGroups(ctx, backupConfigs) |
| 858 | if err != nil { |
| 859 | level.Warn(r.logger).Log("msg", "failed to load some rules backed up by this ruler", "count", len(backupConfigs)-len(loadedBackupConfigs), "err", err) |
| 860 | } |
| 861 | return loadedOwnedConfigs, loadedBackupConfigs, nil |
| 862 | } |
| 863 | return loadedOwnedConfigs, nil, nil |
| 864 | } |
| 865 | |
| 866 | func (r *Ruler) listRules(ctx context.Context) (owned map[string]rulespb.RuleGroupList, backedUp map[string]rulespb.RuleGroupList, err error) { |
| 867 | switch { |
no test coverage detected