-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Improve restoring of access entities' dependencies #2 #69563
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
alexey-milovidov
merged 14 commits into
ClickHouse:master
from
vitlibar:restore-access-dependencies-2
Sep 28, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3c4d650
Refactoring of the code for making a backup and restoring access enti…
vitlibar 91a91be
Add some logging to restoring access entities.
vitlibar 6b461fc
Remove unresolved dependencies while restoring with "allow_unresolved…
vitlibar 64b7e2d
Add UUID to UpdateFunc in IAccessStorage.
vitlibar 9247b32
Add new restore setting "update_access_entities_dependents" to allow …
vitlibar 94f4b4d
Add more tests.
vitlibar 712a726
Change filenames of files with access entities inside a backup:
vitlibar 1a13355
Extend IAccessStorage::findAll() to enable finding all the entities i…
vitlibar f8aec64
Support writing dependents of access entities to backup, added backup…
vitlibar 2d186bf
Make restore setting "skip_unresolved_access_dependencies" work for d…
vitlibar d34b509
Rename restore setting "allow_unresolved_access_dependencies" -> "ski…
vitlibar f2a0dd9
Enable by default backup setting "write_access_entities_dependents".
vitlibar 6bd7a74
Enable by default restore setting "update_access_entities_dependents".
vitlibar 8a7a411
Add one more test.
vitlibar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,6 +176,16 @@ std::vector<UUID> GrantedRoles::findDependencies() const | |
| return res; | ||
| } | ||
|
|
||
| bool GrantedRoles::hasDependencies(const std::unordered_set<UUID> & ids) const | ||
| { | ||
| for (const auto & role_id : roles) | ||
| { | ||
| if (ids.contains(role_id)) | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| void GrantedRoles::replaceDependencies(const std::unordered_map<UUID, UUID> & old_to_new_ids) | ||
| { | ||
| std::vector<UUID> new_ids; | ||
|
|
@@ -221,4 +231,56 @@ void GrantedRoles::replaceDependencies(const std::unordered_map<UUID, UUID> & ol | |
| } | ||
| } | ||
|
|
||
| void GrantedRoles::copyDependenciesFrom(const GrantedRoles & src, const std::unordered_set<UUID> & ids) | ||
| { | ||
| bool found = false; | ||
|
|
||
| for (const auto & role_id : src.roles) | ||
| { | ||
| if (ids.contains(role_id)) | ||
| { | ||
| roles.emplace(role_id); | ||
| found = true; | ||
| } | ||
| } | ||
|
|
||
| if (found) | ||
| { | ||
| for (const auto & role_id : src.roles_with_admin_option) | ||
| { | ||
| if (ids.contains(role_id)) | ||
| roles_with_admin_option.emplace(role_id); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void GrantedRoles::removeDependencies(const std::unordered_set<UUID> & ids) | ||
| { | ||
| bool found = false; | ||
|
|
||
| for (auto it = roles.begin(); it != roles.end();) | ||
| { | ||
| if (ids.contains(*it)) | ||
| { | ||
| it = roles.erase(it); | ||
| found = true; | ||
| } | ||
| else | ||
| { | ||
| ++it; | ||
| } | ||
| } | ||
|
|
||
| if (found) | ||
| { | ||
| for (auto it = roles_with_admin_option.begin(); it != roles_with_admin_option.end();) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. erase_if? |
||
| { | ||
| if (ids.contains(*it)) | ||
| it = roles_with_admin_option.erase(it); | ||
| else | ||
| ++it; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy_if?