Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

python3 -m synapse.config attempts to create directories for the media store #12861

Closed
symphorien opened this issue May 24, 2022 · 4 comments
Closed

Comments

@symphorien
Copy link

It would be nice if it was possible to validate the syntax of config file without running synapse (and possibly without having access to the network, database, certificates etc). It allows to validate config before restarting synapse and possibly having it not restart because of a typo. It would also allow config validation at "build time" before deployment for example on NixOS.

Random examples of prior work:
postgres -C
sshd -t
varnishd -C
nagios -v
collectd -t

nginx has a similar possibility but it insists in reading all certificates so you can't do the syntax check on another machine pre-deployment.

Originally posted by @symphorien in #12651 (comment)

It's possible to do something close now:

venv $  python3 -m synapse.config -c ~/src/nixpkgs/homeserver.yaml 
You have set two incompatible options, expiry_time and expire_caches. Please only use the expire_caches and cache_entry_ttl options and delete the expiry_time option as it is deprecated.
Expiry_time is a deprecated option, please use the expire_caches and cache_entry_ttl options instead.
Traceback (most recent call last):
  File "/nix/store/wnrc4daqbd6v5ifqlxsj75ky8556zy0p-python3-3.9.12/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/nix/store/wnrc4daqbd6v5ifqlxsj75ky8556zy0p-python3-3.9.12/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/venv/lib/python3.9/site-packages/synapse/config/__main__.py", line 56, in <module>
    main(sys.argv)
  File "/tmp/venv/lib/python3.9/site-packages/synapse/config/__main__.py", line 30, in main
    config = HomeServerConfig.load_config("", load_config_args)
  File "/tmp/venv/lib/python3.9/site-packages/synapse/config/_base.py", line 461, in load_config
    obj, _ = cls.load_config_with_parser(config_parser, argv)
  File "/tmp/venv/lib/python3.9/site-packages/synapse/config/_base.py", line 532, in load_config_with_parser
    obj.parse_config_dict(
  File "/tmp/venv/lib/python3.9/site-packages/synapse/config/_base.py", line 718, in parse_config_dict
    self.invoke_all(
  File "/tmp/venv/lib/python3.9/site-packages/synapse/config/_base.py", line 347, in invoke_all
    res[config_class.section] = getattr(config, func_name)(*args, **kwargs)
  File "/tmp/venv/lib/python3.9/site-packages/synapse/config/repository.py", line 120, in read_config
    self.media_store_path = self.ensure_directory(
  File "/tmp/venv/lib/python3.9/site-packages/synapse/config/_base.py", line 199, in ensure_directory
    os.makedirs(dir_path, exist_ok=True)
  File "/nix/store/wnrc4daqbd6v5ifqlxsj75ky8556zy0p-python3-3.9.12/lib/python3.9/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/nix/store/wnrc4daqbd6v5ifqlxsj75ky8556zy0p-python3-3.9.12/lib/python3.9/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/var/lib/matrix-synapse'

but as you can see it actually runs the full server and could not be done on another machine or in a sandbox.

@richvdh
Copy link
Member

richvdh commented May 24, 2022

but as you can see it actually runs the full server and could not be done on another machine or in a sandbox.

no, it does not run the full server. Attempting to create directories is a bug in this instance - but if those directories exist or are successfully created, the command will exit rather than start listening on any ports, etc.

@richvdh richvdh changed the title Feature request: command to validate the syntax of the config file python3 -m synapse.config attempts to create directories for the media store May 24, 2022
@richvdh
Copy link
Member

richvdh commented May 24, 2022

Actually, I'm going to close this as invalid - it doesn't make any sense as it stands.

@richvdh richvdh closed this as completed May 24, 2022
@richvdh
Copy link
Member

richvdh commented May 24, 2022

closed in favour of #12862

@qknight
Copy link

qknight commented Sep 20, 2022

symphorien referenced this issue in nixcloud/nixcloud-webservices Sep 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants