diff --git a/hosts b/hosts index aaa4de9..80e65c7 100644 --- a/hosts +++ b/hosts @@ -1,42 +1,50 @@ test-machines: hosts: vlorentz-desktop: ansible_host: vlorentz-desktop.internal.softwareheritage.org ansible_user: vlorentz-cassandra cassandra_data_root: /srv/softwareheritage/cassandra-test-0 cassandra_max_heap_size: 8G cassandra_heap_newsize: 1200M listen_address: 128.93.66.190 - swh_storage_ports: [12301, 12302, 12303, 12304, 12305, 12306, 12307, 12308] + swh_storage_ports: [12301, 12302, 12303, 12304, 12305, 12306, 12307, 12308, 12309, 12310, 12311, 12312] ardumont-desktop: ansible_host: ardumont-desktop.internal.softwareheritage.org ansible_user: vlorentz-cassandra cassandra_data_root: /data cassandra_max_heap_size: 8G cassandra_heap_newsize: 1200M listen_address: 128.93.66.187 swh_storage_ports: [12301, 12302, 12303, 12304, 12305, 12306] ddouard-desktop: ansible_host: ddouard-desktop.internal.softwareheritage.org ansible_user: vlorentz cassandra_data_root: /data/vlorentz cassandra_max_heap_size: 8G cassandra_heap_newsize: 1200M listen_address: 128.93.66.191 swh_storage_ports: [12301, 12302, 12303, 12304, 12305, 12306] seirl-desktop: - ansible_host: grand-palais.internal.softwareheritage.org + ansible_host: grandpalais.internal.softwareheritage.org ansible_user: vlorentz cassandra_data_root: /mnt/cassandra-test-0 cassandra_max_heap_size: 8G cassandra_heap_newsize: 800M listen_address: 128.93.64.42 swh_storage_ports: [12301, 12302, 12303, 12304, 12305, 12306] + ftigeot-desktop: + ansible_host: petitpalais.internal.softwareheritage.org + ansible_user: vlorentz + seed_address: 128.93.66.190 + swh_storage_ports: [12301, 12302, 12303, 12304, 12305, 12306] cassandra-servers: - children: - test-machines + hosts: + vlorentz-desktop: {} + ardumont-desktop: {} + ddouard-desktop: {} + seirl-desktop: {} cassandra-clients: children: test-machines diff --git a/playbooks/files/werkzeug_log_level.patch b/playbooks/files/werkzeug_log_level.patch new file mode 100644 index 0000000..abdaa61 --- /dev/null +++ b/playbooks/files/werkzeug_log_level.patch @@ -0,0 +1,20 @@ +diff --git a/swh/storage/cli.py b/swh/storage/cli.py +index fe89a69..28db754 100644 +--- a/swh/storage/cli.py ++++ b/swh/storage/cli.py +@@ -28,11 +28,14 @@ def storage(ctx): + help="Binding port of the server") + @click.option('--debug/--no-debug', default=True, + help="Indicates if the server should run in debug mode") +-def serve(config_path, host, port, debug): ++@click.pass_context ++def serve(ctx, config_path, host, port, debug): + '''Software Heritage Storage RPC server. + + Do NOT use this in a production environment. + ''' ++ if 'log_level' in ctx.obj: ++ logging.getLogger('werkzeug').setLevel(ctx.obj['log_level']) + api_cfg = load_and_check_config(config_path, type='any') + app.config.update(api_cfg) + app.run(host, port=int(port), debug=bool(debug)) diff --git a/playbooks/install-replayer.yml b/playbooks/install-replayer.yml index 95068e8..97738f2 100644 --- a/playbooks/install-replayer.yml +++ b/playbooks/install-replayer.yml @@ -1,56 +1,60 @@ - hosts: cassandra-clients tasks: - name: "set journal source location" set_fact: journal_source: "/home/{{ansible_user}}/swh-journal" - name: "get swh-journal's source" git: dest: "{{journal_source}}" repo: "https://forge.softwareheritage.org/source/swh-journal.git" force: yes - name: "fix 'replay' command for recent versions of click" shell: "sed -i \"s/'--group-id', '--consumer-id'/'--group-id'/\" {{journal_source}}/swh/journal/cli.py" - name: "update replayer" copy: src: replay.py dest: "{{journal_source}}/swh/journal/replay.py" - name: "write dummy version file" # to please vcversioner copy: content: "0.0.0-foo-bar" dest: "{{journal_source}}/version.txt" - name: "install swh-journal" shell: "python3 setup.py develop --user" args: chdir: "{{journal_source}}" - name: "copy replayer config file" template: src: "replayer.yml" dest: "/home/{{ansible_user}}/replayer_{{item}}.yml" vars: rpc_port: "{{item}}" with_items: "{{swh_storage_ports}}" + - name: "create systemd unit dir" + file: + path: "/home/{{ansible_user}}/.config/systemd/user/" + state: directory - name: "install replayer systemd unit" template: src: "replayer@.service" dest: "/home/{{ansible_user}}/.config/systemd/user/replayer@.service" - name: "enable systemd unit" systemd: name: "replayer@{{item}}.service" enabled: yes user: yes daemon_reload: yes # https://github.com/ansible/ansible/issues/36585 with_items: "{{swh_storage_ports}}" - name: "restart replayer" systemd: name: "replayer@{{item}}.service" state: restarted user: yes with_items: "{{swh_storage_ports}}" diff --git a/playbooks/install-storage.yml b/playbooks/install-storage.yml index 2b21def..7f35d51 100644 --- a/playbooks/install-storage.yml +++ b/playbooks/install-storage.yml @@ -1,46 +1,56 @@ - hosts: cassandra-clients tasks: - name: "set rpc server source location" set_fact: storage_source: "/home/{{ansible_user}}/swh-storage" - name: "get swh-storage-cassandra's source" git: dest: "{{storage_source}}" repo: "https://forge.softwareheritage.org/source/swh-storage-cassandra.git" version: "cassandra-backend2" remote: "origin-cassandra" + force: yes + + - name: "patch wergzeug log level" + patch: + src: "werkzeug_log_level.patch" + dest: "{{storage_source}}/swh/storage/cli.py" - name: "write dummy version file" # to please vcversioner copy: content: "0.0.999999--" dest: "{{storage_source}}/version.txt" - name: "install swh-storage-cassandra" shell: "python3 setup.py develop --user" args: chdir: "{{storage_source}}" - name: "copy rpc server config file" template: src: "storage_cassandra.yml" dest: "/home/{{ansible_user}}/storage_cassandra.yml" + - name: "create systemd unit dir" + file: + path: "/home/{{ansible_user}}/.config/systemd/user/" + state: directory - name: "install swh-storage-cassandra systemd unit" template: src: "swh-storage-cassandra@.service" dest: "/home/{{ansible_user}}/.config/systemd/user/swh-storage-cassandra@.service" - name: "enable systemd unit" systemd: name: "swh-storage-cassandra@{{item}}.service" enabled: yes user: yes daemon_reload: yes # https://github.com/ansible/ansible/issues/36585 with_items: "{{swh_storage_ports}}" - name: "start swh-storage-cassandra" systemd: name: "swh-storage-cassandra@{{item}}.service" state: restarted user: yes with_items: "{{swh_storage_ports}}" diff --git a/playbooks/templates/replayer@.service b/playbooks/templates/replayer@.service index bdb12c0..bc3af20 100644 --- a/playbooks/templates/replayer@.service +++ b/playbooks/templates/replayer@.service @@ -1,14 +1,14 @@ [Unit] -Description=swh-storage RPC server with Cassandra as backend +Description=Kafka to Cassandra replayer After=network.target Requires=swh-storage-cassandra@%i.service [Service] Type=simple ExecStart=/bin/bash -c 'sleep $(( RANDOM % 60 )); exec /home/{{ansible_user}}/.local/bin/swh journal --config-file /home/{{ansible_user}}/replayer_%i.yml replay --broker esnode1.internal.softwareheritage.org --group-id vlorentz-cassandra-test-0' Restart=on-failure Environment=PYTHONUNBUFFERED=1 SyslogIdentifier=replayer-%i [Install] WantedBy=default.target diff --git a/playbooks/templates/storage_cassandra.yml b/playbooks/templates/storage_cassandra.yml index 5b351cd..acc5392 100644 --- a/playbooks/templates/storage_cassandra.yml +++ b/playbooks/templates/storage_cassandra.yml @@ -1,8 +1,10 @@ storage: cls: cassandra args: - hosts: [{{listen_address}}] + hosts: + - {% if seed_address is defined %}{{seed_address}}{% else %}{{listen_address}}{% endif %} + keyspace: swh_test objstorage: cls: memory args: {}