MCPcopy Create free account
hub / github.com/cortexproject/cortex / SyncRuleGroups

Method SyncRuleGroups

pkg/ruler/manager.go:148–181  ·  view source on GitHub ↗
(ctx context.Context, ruleGroups map[string]rulespb.RuleGroupList)

Source from the content-addressed store, hash-verified

146}
147
148func (r *DefaultMultiTenantManager) SyncRuleGroups(ctx context.Context, ruleGroups map[string]rulespb.RuleGroupList) {
149 // this is a safety lock to ensure this method is executed sequentially
150 r.syncRuleMtx.Lock()
151 defer r.syncRuleMtx.Unlock()
152
153 for userID, ruleGroup := range ruleGroups {
154 r.syncRulesToManager(ctx, userID, ruleGroup)
155 }
156
157 r.userManagerMtx.Lock()
158 defer r.userManagerMtx.Unlock()
159
160 // Check for deleted users and remove them
161 for userID, mngr := range r.userManagers {
162 if _, exists := ruleGroups[userID]; !exists {
163 go mngr.Stop()
164 delete(r.userManagers, userID)
165
166 r.removeNotifier(userID)
167 r.mapper.cleanupUser(userID)
168 r.userExternalLabels.remove(userID)
169 r.lastReloadSuccessful.DeleteLabelValues(userID)
170 r.lastReloadSuccessfulTimestamp.DeleteLabelValues(userID)
171 r.configUpdatesTotal.DeleteLabelValues(userID)
172 r.userManagerMetrics.RemoveUserRegistry(userID)
173 if r.ruleEvalMetrics != nil {
174 r.ruleEvalMetrics.deletePerUserMetrics(userID)
175 }
176 level.Info(r.logger).Log("msg", "deleted rule manager and local rule files", "user", userID)
177 }
178 }
179
180 r.managersTotal.Set(float64(len(r.userManagers)))
181}
182
183func (r *DefaultMultiTenantManager) updateRuleCache(user string, rules []*promRules.Group) {
184 r.ruleCacheMtx.Lock()

Calls 9

syncRulesToManagerMethod · 0.95
removeNotifierMethod · 0.95
cleanupUserMethod · 0.80
removeMethod · 0.80
StopMethod · 0.65
SetMethod · 0.65
RemoveUserRegistryMethod · 0.45
deletePerUserMetricsMethod · 0.45
LogMethod · 0.45