-
Notifications
You must be signed in to change notification settings - Fork 198
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
Allow Admin API delete room v2 actions to be run on worker #17904
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Allow Admin API delete room v2 actions to be run on workers. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,13 @@ | |
}, | ||
"worker_extra_conf": "enable_media_repo: true", | ||
}, | ||
"admin": { | ||
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. Perhaps we need a comment above for
|
||
"app": "synapse.app.generic_worker", | ||
"listener_resources": ["replication", "admin"], | ||
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.
I'm not confident but I think it may not need The admin API's probably use the various handlers which have the logic built-in to make the write or send it off over replication to the appropriate worker. For example, the When it invalidates caches, it will I'm not sure if we're completely studious about this as looking at the device creation code, it seems a bit sketchy ( In any case, I think the bottom line is any code that isn't doing the "right" thing and asking the appropriate worker to make the "write" should be updated to do so. I haven't deep-dived into whether we have any of those problems now. |
||
"endpoint_patterns": ["^/_synapse/admin/v2/rooms/.*$"], | ||
"shared_extra_conf": {}, | ||
"worker_extra_conf": "", | ||
}, | ||
"appservice": { | ||
"app": "synapse.app.generic_worker", | ||
"listener_resources": [], | ||
|
@@ -574,6 +581,7 @@ def is_sharding_allowed_for_worker_type(worker_type: str) -> bool: | |
"receipts", | ||
"typing", | ||
"to_device", | ||
"admin", | ||
] | ||
|
||
|
||
|
@@ -1076,6 +1084,7 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None: | |
# Split type names by comma, ignoring whitespace. | ||
worker_types = split_and_strip_string(worker_types_env, ",") | ||
requested_worker_types = parse_worker_types(worker_types) | ||
log(f"requested_worker_types {requested_worker_types}") | ||
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. Remove debug log? |
||
|
||
# Always regenerate all other config files | ||
log("Generating worker config files") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -329,6 +329,16 @@ with `client` and `federation` `resources` must be configured in the | |
[`worker_listeners`](usage/configuration/config_documentation.md#worker_listeners) | ||
option in the worker config. | ||
|
||
The following admin APIs are now available to be handled by workers, with more forthcoming: | ||
|
||
# Admin APIs | ||
"^/_synapse/admin/v2/rooms/.*$" | ||
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. This regex currently matches anything after But I think we want the following explicit list based on what
For example, we don't support the I guess this also applies to the |
||
|
||
Note that a [HTTP listener](usage/configuration/config_documentation.md#listeners) | ||
with `admin` and `replication `resources` must be configured in the | ||
[`worker_listeners`](usage/configuration/config_documentation.md#worker_listeners) | ||
option in the worker config. | ||
|
||
#### Load balancing | ||
|
||
It is possible to run multiple instances of this worker app, with incoming requests | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,6 +191,7 @@ def generate_ip_set( | |
"openid", | ||
"replication", | ||
"static", | ||
"admin", | ||
} | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,6 +168,32 @@ def process_replication_position( | |
self._un_partial_stated_rooms_stream_id_gen.advance(instance_name, token) | ||
return super().process_replication_position(stream_name, instance_name, token) | ||
|
||
async def block_room(self, room_id: str, user_id: str) -> None: | ||
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. It looks like this was moved but |
||
"""Marks the room as blocked. | ||
|
||
Can be called multiple times (though we'll only track the last user to | ||
block this room). | ||
|
||
Can be called on a room unknown to this homeserver. | ||
|
||
Args: | ||
room_id: Room to block | ||
user_id: Who blocked it | ||
""" | ||
await self.db_pool.simple_upsert( | ||
table="blocked_rooms", | ||
keyvalues={"room_id": room_id}, | ||
values={}, | ||
insertion_values={"user_id": user_id}, | ||
desc="block_room", | ||
) | ||
await self.db_pool.runInteraction( | ||
"block_room_invalidation", | ||
self._invalidate_cache_and_stream, | ||
self.is_room_blocked, | ||
(room_id,), | ||
) | ||
|
||
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. It's not super clear from the diff but this was moved from the |
||
async def store_room( | ||
self, | ||
room_id: str, | ||
|
@@ -2493,32 +2519,6 @@ async def add_room_report( | |
) | ||
return next_id | ||
|
||
async def block_room(self, room_id: str, user_id: str) -> None: | ||
"""Marks the room as blocked. | ||
|
||
Can be called multiple times (though we'll only track the last user to | ||
block this room). | ||
|
||
Can be called on a room unknown to this homeserver. | ||
|
||
Args: | ||
room_id: Room to block | ||
user_id: Who blocked it | ||
""" | ||
await self.db_pool.simple_upsert( | ||
table="blocked_rooms", | ||
keyvalues={"room_id": room_id}, | ||
values={}, | ||
insertion_values={"user_id": user_id}, | ||
desc="block_room", | ||
) | ||
await self.db_pool.runInteraction( | ||
"block_room_invalidation", | ||
self._invalidate_cache_and_stream, | ||
self.is_room_blocked, | ||
(room_id,), | ||
) | ||
|
||
async def unblock_room(self, room_id: str) -> None: | ||
"""Remove the room from blocking list. | ||
|
||
|
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.
If we were to stick with Complement, probably belongs in the Synapse repo but would require some boilerplate to get it working.
But since it's a Synapse specific thing, we probably prefer to just write a Twisted test instead (I'm no dictator on this so feel free to ask in the Synapse rooms what people think). If we want it at the end-to-end level, probably in
tests/rest/admin
with some worker override config