Skip to content

Perform final tenant cleanup after last block is deleted. #3613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 4, 2021
Merged

Perform final tenant cleanup after last block is deleted. #3613

merged 9 commits into from
Jan 4, 2021

Conversation

pstibrany
Copy link
Contributor

@pstibrany pstibrany commented Dec 17, 2020

What this PR does: This PR implements final tenant cleanup after some delay since last tenant's block has been deleted. Cleanup will remove all remaining marker files (including tenant deletion), and meta.json files stored under <tenant>/debug/meta prefix.

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good job, LGTM! I just left few nits.

Comment on lines 62 to 63
RuleGroupsDeleted bool `json:"rule_groups_deleted,omitempty"`
AlertManagerConfigDeleted bool `json:"alert_manager_config_deleted,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The omitempty will cause rule_groups_deleted and alert_manager_config_deleted to be omitted from the response until their value is false. I think it's more clear if we always include them. Currently, they're not supported, but that's another way to clearly state rules and alertmanager config hasn't been deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason for hiding them was exactly because they are not supported yet. Once support is added, I would remove omitempty.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, as you prefer. I think it was clear to state they're not supported having them always exported with the false value, but your way works too.

return nil
}

level.Info(userLogger).Log("msg", "cleaning up remaining tenant data")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this log message useful? If so, I would improve the log message. This log comes from the compactor and this generic message may not be clear to the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will improve it. I think it's useful to know when final deletion was done.

}

// If we have just deleted some blocks, update "finished" time. Also update "finished" time if it wasn't set yet, but there are no blocks.
// Note: this UPDATES the tenant deletion mark. Components that use caching bucket will NOT SEE this update,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance of multiple callers updating it? I assume if they do they will write similar times and it will be ok?

Copy link
Contributor Author

@pstibrany pstibrany Jan 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within one compactor, it is only called once.

Multiple compactors may happen to call this method concurrently (eg. one compactor is doing compaction cleanup, and another compactor starts and "takes over" the user). In that case, they may overwrite each-others timestamp if they both happen to delete some blocks or read tenant deletion mark with no timestamp. In that case last write will win, which will delay eventual final cleanup of data for tenant.

@pstibrany
Copy link
Contributor Author

Very good job, LGTM! I just left few nits.

Thanks for your review. I've addressed your feedback, and PR is ready for another look.

Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@pstibrany pstibrany merged commit 532bcb5 into cortexproject:master Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants