-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor how media_repository
is configured
#72
Open
realtyem
wants to merge
11
commits into
unraid_develop
Choose a base branch
from
upstream/media-repo-take-3
base: unraid_develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
realtyem
commented
Nov 21, 2022
@@ -1584,7 +1584,8 @@ Config options related to Synapse's media store. | |||
### `enable_media_repo` | |||
|
|||
Enable the media store service in the Synapse master. Defaults to true. | |||
Set to false if you are using a separate media store worker. | |||
Set to false if you are using a separate media repository worker(and remember to set to |
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.
This is the only place that got changed in this file. Everything else is my editor happily removing whitespace without asking 🙄. It should be easier to look through if you disable whitespace changes.
Maintain backwards compatibility with legacy app names.
...and that the synapse.app.media_repository can a generic_worker if you set enable_media_repo to True.
realtyem
force-pushed
the
upstream/media-repo-take-3
branch
from
November 23, 2022 17:43
b717124
to
c4388b9
Compare
realtyem
force-pushed
the
unraid_develop
branch
from
December 3, 2022 01:59
b7d2303
to
ebe9f9e
Compare
realtyem
force-pushed
the
unraid_develop
branch
3 times, most recently
from
February 5, 2023 08:55
bee4a8c
to
09d98ca
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refactor how
media_repository
is configuredThe code that enables the media repository functions in
repository.py
is really confusing. Let's clean that up by refactoring(while preserving backwards compatibility), then move it to theworker
section of config instead ofserver
. After that, docs to show how to makesynapse.app.media_repository
be asynapse.app.generic_worker
.enable_media_repo
to be easier to read. Also easier to remove reference tosynapse.app.media_repository
.server.py
toworkers.py
. Don't forget to move theWorkerConfig
to just aboveContentRepositoryConfig
. Remove orphaned code.enable_media_repo
being able to be set inworker.yaml
file totrue
if disabled inhomeserver.yaml
or shared.pusher
andfederation_sender
, which can only be done in theworker
config file.synapse-unraid/synapse/config/repository.py
Lines 120 to 130 in e1b15f2
Is the code that references
synapse.app.media_repository
. As I understand it, this is the only piece that is standing in the way of removing the last reference to thisworker_type
. Splitting the conditional and nesting it will allow for simple line removal when it's time to rip it out. A side effect of how this is written is that ifenable_media_repo
is set tofalse
inhomeserver.yaml
or a shared configuration, it can be set totrue
in aworker.yaml
file to enable the functionality correctly for that worker, even if theworker_app
is NOT declared to besynapse.app.media_repository
. That took me over a week to work out in my head, and is a fact not spelled out in the docs.The code that checks what settings were read from yaml is here:
synapse-unraid/synapse/config/server.py
Lines 350 to 355 in 163a58e
Why? There doesn't seem to be a good reason, although there is one other reference to this in the
server
config section atsynapse-unraid/synapse/app/homeserver.py
Lines 210 to 223 in 163a58e
ServerConfig
is loaded beforeContentRepositoryConfig
, thenWorkerConfig
. Checking the code paths didn't yield any issues with moving this around so I'll put it inWorkerConfig
, provided it's moved up to just aboveContentRepositoryConfig
so it would be available. This feels more "right".While this is all being fixed, update how it's read so we can reuse the backwards compatilbity function that is used by
federation_sender
andpusher
to give us the capability to use amedia_repo_instances
map for free.(This part is waiting on the acceptance of the PR in the matrix-org repo, # 14496). It should look something like:Questions:
Full set of conditionals
This was educational when played with at https://www.w3schools.com/python/trypython.asp?filename=demo_variables4
And leads to the question: If there is a deployment with a master and one generic_worker, and the assumption(based on docs) that
enable_media_repo
is left out so it should be on the main process, does it?enable_media_repo
defaults to true, so it should by default be enabled on all instances and workers. This sounds dangerous and expensive, but in practice isn't a big deal because workers by default won't be receiving data over their/_matrix/media
endpoints. However:synapse-unraid/synapse/config/repository.py
Lines 131 to 135 in 163a58e
Jumps to
synapse-unraid/synapse/rest/media/v1/preview_url_resource.py
Lines 201 to 208 in 5e0cb6c
Which passes to
synapse-unraid/synapse/rest/media/v1/preview_url_resource.py
Lines 222 to 225 in 5e0cb6c
Where it sets up a looping call to run the "clean up old url_preview media" function, which then deletes files and directorys in the "media_store" based on whatever worker(or master) got there first. My issue with this is that it does this every 10 seconds. On every worker. Again, doesn't seem to be a big deal since no one seems to have complained about it yet. Should probably make sure that this is explicitly the main process unless it's declared otherwise. I believe that changing
synapse-unraid/synapse/config/repository.py
Lines 133 to 135 in 163a58e
to
will cleanly take care of always setting this to the main process, which also means the conditional check
synapse-unraid/synapse/rest/media/v1/preview_url_resource.py
Line 206 in 163a58e
can be removed as it will never be
None
.Oddity number 37:
Comparing
synapse-unraid/synapse/app/homeserver.py
Lines 210 to 223 in c1da996
and
synapse-unraid/synapse/app/generic_worker.py
Lines 250 to 271 in c1da996
homeserver.py
and Line 251 ingeneric_worker.py
are not comparing the same type of config section. Shouldn't these match? Either one should work™️.