| 401 | } |
| 402 | |
| 403 | func (c *BlocksCleaner) scanUsers(ctx context.Context) ([]string, []string, error) { |
| 404 | active, deleting, deleted, err := c.usersScanner.ScanUsers(ctx) |
| 405 | if err != nil { |
| 406 | return nil, nil, errors.Wrap(err, "failed to discover users from bucket") |
| 407 | } |
| 408 | |
| 409 | isActive := util.StringsMap(active) |
| 410 | markedForDeletion := make([]string, 0, len(deleting)+len(deleted)) |
| 411 | markedForDeletion = append(markedForDeletion, deleting...) |
| 412 | markedForDeletion = append(markedForDeletion, deleted...) |
| 413 | isMarkedForDeletion := util.StringsMap(markedForDeletion) |
| 414 | allUsers := append(active, markedForDeletion...) |
| 415 | // Delete per-tenant metrics for all tenants not belonging anymore to this shard. |
| 416 | // Such tenants have been moved to a different shard, so their updated metrics will |
| 417 | // be exported by the new shard. |
| 418 | for _, userID := range c.lastOwnedUsers { |
| 419 | if !isActive[userID] && !isMarkedForDeletion[userID] { |
| 420 | c.tenantBlocks.DeleteLabelValues(userID) |
| 421 | c.tenantParquetBlocks.DeleteLabelValues(userID) |
| 422 | c.tenantParquetUnConvertedBlocks.DeleteLabelValues(userID) |
| 423 | c.tenantBlocksMarkedForDelete.DeleteLabelValues(userID) |
| 424 | c.tenantBlocksMarkedForNoCompaction.DeleteLabelValues(userID) |
| 425 | c.tenantPartialBlocks.DeleteLabelValues(userID) |
| 426 | c.tenantBucketIndexLastUpdate.DeleteLabelValues(userID) |
| 427 | if c.cfg.ShardingStrategy == util.ShardingStrategyShuffle { |
| 428 | c.remainingPlannedCompactions.DeleteLabelValues(userID) |
| 429 | if c.cfg.CompactionStrategy == util.CompactionStrategyPartitioning { |
| 430 | c.inProgressCompactions.DeleteLabelValues(userID) |
| 431 | c.oldestPartitionGroupOffset.DeleteLabelValues(userID) |
| 432 | } |
| 433 | } |
| 434 | } |
| 435 | } |
| 436 | c.lastOwnedUsers = allUsers |
| 437 | |
| 438 | return active, markedForDeletion, nil |
| 439 | } |
| 440 | |
| 441 | func (c *BlocksCleaner) obtainVisitMarkerManager(ctx context.Context, userLogger log.Logger, userBucket objstore.InstrumentedBucket) (visitMarkerManager *VisitMarkerManager, isVisited bool, err error) { |
| 442 | cleanerVisitMarker := NewCleanerVisitMarker(c.ringLifecyclerID) |