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

Method DeleteTenantConfiguration

pkg/ruler/ruler.go:1581–1600  ·  view source on GitHub ↗
(w http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

1579}
1580
1581func (r *Ruler) DeleteTenantConfiguration(w http.ResponseWriter, req *http.Request) {
1582 logger := util_log.WithContext(req.Context(), r.logger)
1583
1584 userID, err := users.TenantID(req.Context())
1585 if err != nil {
1586 // When Cortex is running, it uses Auth Middleware for checking X-Scope-OrgID and injecting tenant into context.
1587 // Auth Middleware sends http.StatusUnauthorized if X-Scope-OrgID is missing, so we do too here, for consistency.
1588 http.Error(w, err.Error(), http.StatusUnauthorized)
1589 return
1590 }
1591
1592 err = r.store.DeleteNamespace(req.Context(), userID, "") // Empty namespace = delete all rule groups.
1593 if err != nil && !errors.Is(err, rulestore.ErrGroupNamespaceNotFound) {
1594 util_api.RespondError(logger, w, v1.ErrServer, err.Error(), http.StatusInternalServerError)
1595 return
1596 }
1597
1598 level.Info(logger).Log("msg", "deleted all tenant rule groups", "user", userID)
1599 w.WriteHeader(http.StatusOK)
1600}
1601
1602func (r *Ruler) ListAllRules(w http.ResponseWriter, req *http.Request) {
1603 logger := util_log.WithContext(req.Context(), r.logger)

Callers 2

callDeleteTenantAPIFunction · 0.80

Calls 6

TenantIDFunction · 0.92
DeleteNamespaceMethod · 0.65
ContextMethod · 0.45
ErrorMethod · 0.45
IsMethod · 0.45
LogMethod · 0.45

Tested by 2

callDeleteTenantAPIFunction · 0.64