Skip to content
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

Docker Swarm compatibility #55

Closed
FinlayDaG33k opened this issue Dec 12, 2022 · 4 comments · Fixed by #57
Closed

Docker Swarm compatibility #55

FinlayDaG33k opened this issue Dec 12, 2022 · 4 comments · Fixed by #57

Comments

@FinlayDaG33k
Copy link
Contributor

Hii there,

I'm trying to get mktxp working within Docker swarm, however, I'm running into some issues.
When I try to use a volume and put my mktxp.conf and _mktxp.conf inside, I get the following error because the container isn't using the default user (hence, I cannot set the proper permissions):

Traceback (most recent call last):
  File "/usr/local/bin/mktxp", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mktxp/cli/dispatch.py", line 105, in main
    MKTXPDispatcher().dispatch()
  File "/usr/local/lib/python3.11/site-packages/mktxp/cli/dispatch.py", line 39, in dispatch
    self.start_export(args)
  File "/usr/local/lib/python3.11/site-packages/mktxp/cli/dispatch.py", line 89, in start_export
    ExportProcessor.start()
  File "/usr/local/lib/python3.11/site-packages/mktxp/flow/processor/base_proc.py", line 35, in start
    REGISTRY.register(CollectorHandler(RouterEntriesHandler(), CollectorRegistry()))
                                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mktxp/flow/router_entries_handler.py", line 25, in __init__
    entry = config_handler.config_entry(router_name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mktxp/cli/config/config.py", line 199, in config_entry
    entry_reader = self._config_entry_reader(entry_name)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mktxp/cli/config/config.py", line 245, in _config_entry_reader
    self.config.write()
  File "/usr/local/lib/python3.11/site-packages/configobj.py", line 2128, in write
    with open(self.filename, 'wb') as h:
         ^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/home/mktxp/mktxp/mktxp.conf'

Using a config however, causes the startup to fail because the program sees it as a read-only filesystem (which is normal behaviour for a config in Docker Swarm.

version: '3.7'
services:
  mktxp:
    image: ghcr.io/akpw/mktxp:gha-3665068086
    volumes:
      - type: volume
        source: mktxp-data
        target: /home/mktxp/mktxp
    configs:
      - source: mktxp-config
        target: "/home/mktxp/mktxp/mktxp.conf"
      - source: mktxp2-config
        target: "/home/mktxp/mktxp/_mktxp.conf"
    networks:
      - default
      - bridge
networks:
  default:
    internal: true
    driver: overlay
  bridge:
    external: true
volumes:
  mktxp-data:
    driver: local
configs:
  mktxp-config:
    name: "mktxp.conf-2022_12_12-1015"
    external: true
  mktxp2-config:
    name: "mktxp2.conf-2022_12_12-1246"
    external: true
OSError: [Errno 30] Read-only file system: '/home/mktxp/mktxp/mktxp.conf'

Having proper compatibility with Docker Swarm would be desired.

@akpw
Copy link
Owner

akpw commented Dec 12, 2022

@FinlayDaG33k this is essentially forward compatibility-related: with new features in upcoming releases, there are also new settings in the mktxp.conf / _mktxp.conf files.

mktxp tries to automatically add those to existing installs using defaults, which obviously could be problematic under a read-only filesystem.

For Docker Swarm / compose systems, the easiest solution is just use the configs files with all settings explicitly set.
You can find examples of those here or in the mktxp-stack configs

@FinlayDaG33k
Copy link
Contributor Author

I see.
Would it maybe be helpful to state this matter in the documentation for people that run into the same issue?

@akpw
Copy link
Owner

akpw commented Dec 16, 2022

@FinlayDaG33k sure it makes sense to mention in FAQ. I will at some point, or just feel free to do a PR in the meantime

@djieno
Copy link

djieno commented May 31, 2023

Similar to above I got the error running the example from the main howto.

SOLVED
After adding the file mktxp/_mktxp.conf like in HERE it worked. I could go to the outputted http://host:port/metrics and see the metrics. Hope this might help someone

docker run -v "$(pwd)/mktxp:/home/mktxp/mktxp/" -p 49090:49090 -it --rm ghcr.io/akpw/mktxp:latest

Connecting to router main@10.1.1.1 2023-05-31 08:48:42 Connection to router main@10.1.1.1 has been established 2023-05-31 08:48:42 Running HTTP metrics server on port 49090 Traceback (most recent call last): File "/usr/local/bin/mktxp", line 8, in <module> sys.exit(main()) ^^^^^^ File "/usr/local/lib/python3.11/site-packages/mktxp/cli/dispatch.py", line 108, in main MKTXPDispatcher().dispatch() File "/usr/local/lib/python3.11/site-packages/mktxp/cli/dispatch.py", line 30, in dispatch args = self.option_parser.parse_options() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/mktxp/cli/options.py", line 72, in parse_options config_handler() File "/usr/local/lib/python3.11/site-packages/mktxp/cli/config/config.py", line 252, in __call__ self._create_os_path(self.mktxp_conf_path, File "/usr/local/lib/python3.11/site-packages/mktxp/cli/config/config.py", line 297, in _create_os_path shutil.copy(lookup_path, os_path) File "/usr/local/lib/python3.11/shutil.py", line 419, in copy copyfile(src, dst, follow_symlinks=follow_symlinks) File "/usr/local/lib/python3.11/shutil.py", line 258, in copyfile with open(dst, 'wb') as fdst: ^^^^^^^^^^^^^^^ **PermissionError: [Errno 13] Permission denied: '/home/mktxp/mktxp/_mktxp.conf'**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants