-
Notifications
You must be signed in to change notification settings - Fork 60
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
Dual Write: Generate replication events for Role endpoints #1172
Conversation
34abb11
to
9b5a83f
Compare
a8185c5
to
88ba65f
Compare
/retest |
rbac/management/role/view.py
Outdated
@@ -371,7 +394,7 @@ def update(self, request, *args, **kwargs): | |||
@apiParam (Path) {String} id Role unique identifier | |||
|
|||
@apiParam (Request Body) {String} name Role name | |||
@apiParam (Request Body) {Array} access Access definition | |||
@apiParam (Request Body) {ArRray} access Access definition |
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.
Might be a small nitpick not sure if the docstrings affect things here but should ArRray
just be Array
?
rbac/management/role/model.py
Outdated
id = models.UUIDField(default=uuid4, primary_key=True) | ||
v1_role = models.ForeignKey(Role, on_delete=models.CASCADE) | ||
v2_role = models.ForeignKey(V2Role, on_delete=models.CASCADE) | ||
permissions = ArrayField(models.CharField(max_length=200), blank=True, null=True) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Also note that since most operations are performed in their own isolated transaction (autocommit / not inside atomic()
) then I think the perf overhead of repeatable read (or serializable for that matter) should be negligible (however you will also not see any of the benefits of the increased isolation level in those cases–it will only matter to atomic()
blocks).
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.
Option 2 was added.
Fixes RHCLOUD-35563
Assumes eventual API change from IT API
[RHCLOUD-35227] Replicate group removal
…rkspace-relations Create proper root/default workspaces on initial migration
…ples RHCLOUD-35448: Start using Principal.user_id for group#member@principal tuples
|
||
def prepare_to_delete_group(self): | ||
"""Generate relations to delete.""" | ||
roles = Role.objects.filter(policies__group=self.group) |
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.
Need to add a check if replication is enabled here
/retest |
…dual write handler
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.
IMO this is ready to ship
RelationApiDualWriteHandler
was added. This class containers has methods which performs Replication Event generationgenerate_relations_from_current_state_of_role
- this generate relations from current stage of role only from PRBAC DB- it uses mappings tables to get v2 role and role bindings uuidsgenerate_relations_and_mappings_for_role
- this generates new relations for role - it generates new UUID for v2 role and role bindingsregenerate_relations_and_mappings_for_role
-generate_relations_and_mappings_for_role
build_replication_event
- generates json representation of relation which are sent to outbox table - see replication event bellowsave_replication_event_to_outbox
- store relation event into outbox table (content of this method is not added yet)generate_replication_event_to_outbox
-regenerate_relations_and_mappings_for_role
andsave_replication_event_to_outbox
Each role action has mix of those methods:
CREATE:
generate_relations_and_mappings_for_role
save_replication_event_to_outbox
UPDATE:
generate_relations_from_current_state_of_role
generate_replication_event_to_outbox
DELETE:
generate_relations_from_current_state_of_role
save_replication_event_to_outbox
v2 role uuid
andpermissions
where added into BindingMapping table ,this information are required to identification of role and role bindings
REPLICATION_TO_RELATION_ENABLED
to enabled and disable replication - Replication is disable by default except to unit testsNext Steps: Missing Endpoints
Replication Event (which will be stored in outbox table as payload):
Links
https://issues.redhat.com/browse/RHCLOUD-34786
https://issues.redhat.com/browse/RHCLOUD-34509