Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2022-02-25 15:52:03 +01:00
parent 9b365b02a7
commit 9e57fb1fd3
No known key found for this signature in database
GPG Key ID: 09AA5403E54D9931
8 changed files with 89 additions and 4 deletions

View File

@ -76,7 +76,7 @@ nodes_layout:
- { branch: 'stable', num: 2 }
- { branch: 'testing', num: 1 }
- { branch: 'testing', num: 2 }
- { branch: 'unstable', num: 1 }
- { branch: 'unstable', num: 1, db_purge: true }
- { branch: 'unstable', num: 2 }
- { branch: 'libp2p', num: 1 }
@ -85,6 +85,6 @@ nodes_layout:
- { branch: 'stable', num: 2 }
- { branch: 'testing', num: 1 }
- { branch: 'testing', num: 2 }
- { branch: 'unstable', num: 1 }
- { branch: 'unstable', num: 1, db_purge: true, db_sync: true }
- { branch: 'unstable', num: 2 }
- { branch: 'libp2p', num: 1 }

View File

@ -61,6 +61,11 @@ nodes_layout:
- { branch: 'testing', start: 8000, end: 10000, build_start: '15:00:00' }
- { branch: 'unstable', start: 12000, end: 14000, build_start: '16:00:00' }
'windows-01.he-eu-hel1.nimbus.prater': # 2000 each
- { branch: 'stable', build_start: '13:00:00' }
- { branch: 'testing', build_start: '15:00:00' }
- { branch: 'unstable', build_start: '16:00:00' }
'windows-01.gc-us-central1-a.nimbus.prater': # 2000 each
- { branch: 'stable', start: 14000, end: 16000, build_start: '13:00:00' }
- { branch: 'testing', start: 16000, end: 18000, build_start: '15:00:00' }

View File

@ -0,0 +1,7 @@
---
# Purge node DB periodically to test syncing.
nimbus_db_purge_node_service_name: '{{ beacon_node_service_name }}'
nimbus_db_purge_node_service_path: '{{ beacon_node_service_path }}'
nimbus_db_purge_node_network_name: '{{ beacon_node_network }}'
nimbus_db_purge_truster_node_api_url: 'http://localhost:1234'
nimbus_db_purge_timer_frequency: 'weekly'

View File

@ -40,3 +40,15 @@
loop_control:
loop_var: node
index_var: port_offset
- name: Configure periodic puging of nodes DBs
become: true
hosts: nimbus-mainnet-metal
tasks:
- include_role: name=nimbus-db-purge
tags: [ nimbus-db-purge ]
when: '{{ node.get("db_purge", false) }}'
with_items: '{{ nodes_layout[hostname] }}'
loop_control:
loop_var: node
index_var: port_offset

View File

@ -26,7 +26,7 @@
- name: infra-role-bootstrap-macos
src: git@github.com:status-im/infra-role-bootstrap-macos.git
version: 46ec39135a4226e1574cb8868ace52f911e97636
version: f2dda03c8a88b5bf7151ef518ed375b185dd67d7
scm: git
- name: infra-role-wireguard
@ -51,7 +51,7 @@
- name: infra-role-beacon-node-windows
src: git@github.com:status-im/infra-role-beacon-node-windows.git
version: 5eab965d005c4f076d4c12ce8a115fc42c8cdc07
version: fcc5fd5078431600801d2b4adc80853d884beb72
scm: git
- name: infra-role-beacon-node-macos

View File

@ -0,0 +1,11 @@
---
#nimbus_db_purge_node_service_name: ~
#nimbus_db_purge_node_service_path: ~
#nimbus_db_purge_node_network_name: ~
#nimbus_db_purge_truster_node_api_url: 'http://localhost:1234'
nimbus_db_purge_timer_name: 'nimbus-db-purge'
nimbus_db_purge_timer_enabled: true
nimbus_db_purge_timer_timeout: 600
nimbus_db_purge_timer_frequency: 'weekly'
nimbus_db_purge_timer_script_path: '{{ nimbus_db_purge_node_service_path | mandatory }}/purge_sync.sh'

View File

@ -0,0 +1,24 @@
---
- name: Create purge and sync script
template:
src: 'purge_sync.sh.j2'
dest: '{{ nimbus_db_purge_timer_script_path }}'
owner: 'root'
group: 'nimbus'
mode: 0750
- name: Create timer for purge script
include_role: name=systemd-timer
vars:
systemd_timer_name: '{{ nimbus_db_purge_timer_name }}'
systemd_timer_description: 'Purge {{ nimbus_db_purge_node_service_name }} DB'
systemd_timer_user: 'root'
systemd_timer_group: 'root'
systemd_timer_start_on_creation: false
systemd_timer_ionice_class: 'idle'
systemd_timer_consul_warning: true
systemd_timer_enabled: '{{ nimbus_db_purge_timer_enabled }}'
systemd_timer_frequency: '{{ nimbus_db_purge_timer_frequency }}'
systemd_timer_timeout_sec: '{{ nimbus_db_purge_timer_timeout }}'
systemd_timer_work_dir: '{{ nimbus_db_purge_node_service_path }}'
systemd_timer_script_path: '{{ nimbus_db_purge_timer_script_path }}'

View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
# vim:ft=sh
set -Eeuo pipefail
TRUSTED_NODE_API_URL='{{ nimbus_db_purge_truster_node_api_url | mandatory }}'
SERVICE_NAME='{{ nimbus_db_purge_node_service_name | mandatory }}'
SERVICE_PATH='{{ nimbus_db_purge_node_service_path | mandatory }}'
NETWORK_NAME='{{ nimbus_db_purge_node_network_name | mandatory }}'
SERVICE_DATA_PATH="${SERVICE_PATH}/data/shared_${NETWORK_NAME}_0/"
echo "Stopping node: ${SERVICE_NAME}"
sudo systemctl stop "${SERVICE_NAME}"
echo "Purging DB: ${SERVICE_DATA_PATH}"
sudo rm -fr "${SERVICE_DATA_PATH}/db"
echo "Syncing from trusted node: ${TRUSTED_NODE_API_URL}"
sudo -u nimbus "${SERVICE_PATH}/repo/build/nimbus_beacon_node" \
trustedNodeSync \
--data-dir="${SERVICE_DATA_PATH}" \
--trusted-node-url="${TRUSTED_NODE_API_URL}" \
--network="${NETWORK_NAME}" \
--backfill=false
echo "Starting node: ${SERVICE_NAME}"
sudo systemctl start "${SERVICE_NAME}"