summary refs log tree commit diff
path: root/docker/configure_workers_and_start.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Move the worker type error checking upfront github/rei/fork_comp-worker-shorthand rei/fork_comp-worker-shorthandOlivier Wilkinson (reivilibre)2023-03-091-12/+9
|
* Try to simplify the nginx generation codeOlivier Wilkinson (reivilibre)2023-03-091-39/+17
|
* Try to simplify parse_worker_typesOlivier Wilkinson (reivilibre)2023-03-091-142/+57
|
* Move final creation of a worker name to after the final check of why it ↵Jason Little2023-03-091-9/+9
| | | | can't exist.
* Try and apply review comments about sanitizing names.Jason Little2023-03-081-34/+49
| | | | | | | | 1. Update a few comments for clarity. 2. Apply a replace() to remove whitespace in a requested worker name and use an underscore instead. 3. Stop-error if requesting a worker name, but forgetting to actually put one in. 4. If a worker name isn't requested, just use the set of worker types, sorted and concatenated with a hyphen. This avoids having to sanitize the worker name in this case. 5. Add regex to avoid nasty name surprises.
* Remove condition based on number of portsJason Little2023-03-081-21/+16
| | | | | ...so that even with a single port, a worker gets it's own upstream. Nginx says this can lead to performance improvements if some features are enabled. Revisit this later.
* Update how worker_type specific options are merged into shared_config, and ↵Jason Little2023-03-081-3/+3
| | | | update comments to match.
* Update comments and a few other texty bits:Jason Little2023-03-071-26/+38
| | | | | 1. Update comments and edit(or create) docstrings and a single type hint that was incomplete(split_and_strip_string()). 2. Rename parse_worker_types_from_env to parse_worker_types as it's not coming from the environment.
* Disambiguate a confusing mess of 'worker_roles', 'workers_roles', ↵Jason Little2023-03-041-28/+28
| | | | 'worker_type', and similar and that should have been 'worker_types' when in use by sets and a couple other places.
* Change function name and fix docstring to be correct.Jason Little2023-03-041-5/+4
|
* Merge branch 'develop' into comp-worker-shorthandJason Little2023-03-031-1/+7
|\
| * Add support for knocking to workers. (#15133)Dirk Klimpel2023-03-021-0/+1
| |
| * Dockerfile-workers: spell out when config isn't generated (#15186)David Robertson2023-03-021-1/+5
| | | | | | | | | | * Complement: Spell out when config isn't generated * Changelog
| * Allow use of the `/filter` Client-Server APIs on workers. (#15134)reivilibre2023-02-281-0/+1
| |
* | Apply changes from review.Jason Little2023-03-031-264/+352
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Factor processing of all worker types from the environment out and away from generating config files. 2. Fix up early templating of 'worker_config' to remove boilerplate. 3. Wrangle nginx upstream processing to accommodate odd combinations for overlapping workers. e.g. 'user_dir, user_dir+presence' should be able to handle the(in this case single) endpoint over either worker. I think this was promised in a previous commit, consider it delivered. 4. Update a bunch of comments, and adjust some pre-existing to fit inside the line length count of 88(aka, make the green squiggles go away) 5. Move processing of unusable characters for worker names to a later position so it will check the name produced if one was not requested as well.
* | Fix conditional and update error message and comments.Jason Little2023-02-181-5/+11
| |
* | Apply changes from review:Jason Little2023-02-181-96/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Turn 'placeholder_name' into a magic constant. 2. Fix casting on a worker_type_list from 'list' to 'List[str]'. 3. In 'insert_worker_name_for_shared_config', use new WORKER_PLACEHOLDER_NAME constant and reduce complexity by using value from items() directly. 4. In 'is_sharding_allowed_for_worker_type', simplify the return value. 5. Adjust 'split_string_and_strip' to allow for using the 'maxsplit' kwarg on 'strip' and update comment. 6. Remove function 'increment_counter' and use 'defaultdict' instead to reduce complexity. 7. Remove function 'is_name_allowed_for_worker', as this can be accomplished with an 'if' statement and only checked for a worker base name in a dict. Adjust 'generate_worker_files' to accommadate. 8. Rename a few dict's to remove misnomer's and adjust comments for extra clarity. 9. In 'generate_worker_files': a. Use 'ValueError' exception handling to catch additional errors when parsing an integer and simplify counting of appended worker_type's. b. Add additional error cases to check(single and double quotes, spaces, and last character being an integer) for potential file name/nginx issues. c. Adjust various variable names to improve readability. 10. Update various comments throughout.
* | Caught a typoJason Little2023-01-261-1/+1
| |
* | Allow for worker types to be merged and given a name.Jason Little2023-01-251-50/+320
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the Synapse-worker docker image, multiple worker types are defined but only allowed to be that one single definition. This makes it so that any two(or more) worker types can be merged into a single worker. For example: 1. If you wish to have one worker with both client_reader and federation_sender functions enabled, you can set SYNAPSE_WORKER_TYPES='client_reader+federation_sender' 2. If you wish to have all stream_writers(excepting event_persister) you can set SYNAPSE_WORKER_TYPES='account_data+presence+receipts+to_device+typing' Multiple types can be combined, but some error checking to dis-allow multiples of worker types that shouldn't be enabled more than once has been added. For example: SYNAPSE_WORKER_TYPES='background_worker+event_persister, background_worker+event_persister' will not work as background_worker is only allowed to have a single worker for the entire deployment. Giving a worker or a combination of workers a custom name is as simple as adding the name then an equal sign in front of the given worker type(s). For example: SYNAPSE_WORKER_TYPES='alice=federation_reader' or SYNAPSE_WORKER_TYPES='bob=federation_inbound+federation_sender' or SYNAPSE_WORKER_TYPES='charlie=event_persister:2, derek=media_repository + pusher + user_dir + appservice + event_creator'
* | Allow for a multipler to be added to a requested worker.Jason Little2023-01-221-1/+36
|/ | | | | | | This allows for appending a ':' and a positive integer to a requested worker type for the SYNAPSE_WORKER_TYPES environment variable(and likewise, the WORKER_TYPES) used in Complement. For example: 'event_persister:2' would be yield identical results of 'event_persister, event_persister'
* Move MSC3030 `/timestamp_to_event` endpoint to stable v1 location (#14471)Eric Eastwood2022-11-281-0/+2
| | | | | | | | Fix https://github.com/matrix-org/synapse/issues/14390 - Client API: `/_matrix/client/unstable/org.matrix.msc3030/rooms/<roomID>/timestamp_to_event?ts=<timestamp>&dir=<direction>` -> `/_matrix/client/v1/rooms/<roomID>/timestamp_to_event?ts=<timestamp>&dir=<direction>` - Federation API: `/_matrix/federation/unstable/org.matrix.msc3030/timestamp_to_event/<roomID>?ts=<timestamp>&dir=<direction>` -> `/_matrix/federation/v1/timestamp_to_event/<roomID>?ts=<timestamp>&dir=<direction>` Complement test changes: https://github.com/matrix-org/complement/pull/559
* Remove need for `worker_main_http_uri` setting to use /keys/upload. (#14400)realtyem2022-11-161-4/+1
|
* Modernize configure_workers_and_start.py bootstrapping script for ↵realtyem2022-11-091-15/+14
| | | | Dockerfile-workers. (#14294)
* Add all Stream Writer worker types to configure_workers_and_start.py (#14197)realtyem2022-11-081-7/+69
| | | Co-authored-by: reivilibre <oliverw@matrix.org>
* Flush stdout/err in Dockerfile-workers before replacing the current process ↵realtyem2022-10-181-12/+8
| | | | | | | (#14195) Also update `subprocess.check_output` to the slightly newer `subprocess.run`. Signed-off-by: Jason Little <realtyem@gmail.com>
* Strip whitespace from worker types in Dockerfile-workers (#14165)realtyem2022-10-141-4/+2
|
* Set LD_PRELOAD to load jemalloc in Dockerfile-workers. (#14182)realtyem2022-10-141-1/+11
|
* Stabilize the threads API. (#14175)Patrick Cloke2022-10-141-0/+1
| | | | | | | Stabilize the threads API (MSC3856) by supporting (only) the v1 path for the endpoint. This also marks the API as safe for workers since it is a read-only API.
* Mark /relations endpoint as usable on workers. (#14028)Patrick Cloke2022-10-121-0/+27
| | | Co-authored-by: Eric Eastwood <erice@element.io>
* Add the ability to set the log level using the `SYNAPSE_TEST_LOG_LEVEL` ↵reivilibre2022-07-051-6/+14
| | | | environment when using `complement.sh`. (#13152)
* Improve startup times in Complement test runs against workers, particularly ↵reivilibre2022-06-301-0/+7
| | | | | in CPU-constrained environments. (#13127) Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Refactor the Dockerfile-workers configuration script to use Jinja2 templates ↵reivilibre2022-06-271-24/+12
| | | | | in Synapse workers' Supervisord blocks. (#13054) Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Use updated `update_user_directory_from_worker` options in Complement tests. ↵reivilibre2022-06-151-3/+3
| | | | (#13069)
* Merge the Complement testing Docker images into a single, multi-purpose ↵reivilibre2022-06-081-8/+14
| | | | | image. (#12881) Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Add the `batch_send` endpoint to generic workers (#12868)Nick Mills-Barrett2022-05-251-0/+1
|
* Support registering Application Services when running with workers under ↵reivilibre2022-05-231-0/+15
| | | | | Complement. (#12826) Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Remove Caddy from the Synapse workers image used in Complement. (#12818)reivilibre2022-05-231-0/+5
|
* Add the `notify_appservices_from_worker` configuration option (superseding ↵reivilibre2022-05-061-2/+2
| | | | `notify_appservices`) to allow a generic worker to be designated as the worker to send traffic to Application Services. (#12452)
* Use supervisord to supervise Postgres and Caddy in the Complement image. ↵reivilibre2022-04-271-1/+1
| | | | | (#12480) Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* disallow-untyped-defs in `docker` and `stubs` directories (#12528)David Robertson2022-04-251-11/+13
|
* Dockerfile-workers: reduce the amount we install (#12464)Richard van der Hoff2022-04-141-10/+9
| | | | This is an attempt to reduce the rebuild time. In short, we reduce the amount of stuff that the dockerfile installs, so as to give a faster startup.
* Dockerfile-workers: give the master its own log config (#12466)Richard van der Hoff2022-04-131-17/+31
| | | | | | | | | | | When we run a worker-mode synapse under docker, everything gets logged to stdout. Currently, output from the workers is tacked with a worker name, for example: ``` 2022-04-13 15:27:56,810 - worker:frontend_proxy1 - synapse.util.caches.lrucache - 154 - INFO - LruCache._expire_old_entries-0 - Dropped 0 items from caches ``` - note `worker:frontend_proxy1`. No such tag is applied to log lines from the master, which makes somewhat confusing reading. To fix this, we generate a dedicated log config file for the master in the same way that we do for the workers, and use that.
* Fix up healthcheck generation for workers docker image (#12405)Richard van der Hoff2022-04-111-7/+9
| | | This wasn't quite generating the right thing.
* Add missing type definitions for scripts in docker folder (#12280)Jorge Florian2022-04-081-4/+5
| | | | Signed-off-by: Jorge Florian <jafn28@gmail.com>
* Create healthcheck script for synapse-workers container (#11429)Michael Kaye2021-11-261-0/+13
| | | | | The intent is to iterate through all the worker ports and only report healthy when all are healthy, starting with the main process.
* Add support for `/_matrix/media/v3` APIs (#11371)Aaron R2021-11-171-11/+11
| | | | | | | | | | | | | * Add support for `/_matrix/media/v3` APIs Signed-off-by: Aaron Raimist <aaron@raim.ist> * Update `workers.md` to use v3 client and media APIs Signed-off-by: Aaron Raimist <aaron@raim.ist> * Add changelog Signed-off-by: Aaron Raimist <aaron@raim.ist>
* Fix frontend_proxy jinja script in docker workers (#10783)kegsay2021-09-081-1/+1
|
* Run complement with Synapse workers manually. (#10039)Patrick Cloke2021-05-241-4/+4
| | | | Adds an option to complement.sh to run Synapse in worker mode (instead of the default monolith mode).
* Add a dockerfile for running a set of Synapse worker processes (#9162)Andrew Morgan2021-04-141-0/+558
This PR adds a Dockerfile and some supporting files to the `docker/` directory. The Dockerfile's intention is to spin up a container with: * A Synapse main process. * Any desired worker processes, defined by a `SYNAPSE_WORKERS` environment variable supplied at runtime. * A redis for worker communication. * A nginx for routing traffic. * A supervisord to start all worker processes and monitor them if any go down. Note that **this is not currently intended to be used in production**. If you'd like to use Synapse workers with Docker, instead make use of the official image, with one worker per container. The purpose of this dockerfile is currently to allow testing Synapse in worker mode with the [Complement](https://github.com/matrix-org/complement/) test suite. `configure_workers_and_start.py` is where most of the magic happens in this PR. It reads from environment variables (documented in the file) and creates all necessary config files for the processes. It is the entrypoint of the Dockerfile, and thus is run any time the docker container is spun up, recreating all config files in case you want to use a different set of workers. One can specify which workers they'd like to use by setting the `SYNAPSE_WORKERS` environment variable (as a comma-separated list of arbitrary worker names) or by setting it to `*` for all worker processes. We will be using the latter in CI. Huge thanks to @MatMaul for helping get this all working :tada: This PR is paired with its equivalent on the Complement side: https://github.com/matrix-org/complement/pull/62. Note, for the purpose of testing this PR before it's merged: You'll need to (re)build the base Synapse docker image for everything to work (`matrixdotorg/synapse:latest`). Then build the worker-based docker image on top (`matrixdotorg/synapse:workers`).