From 8c0034dd96955e32f4fb1492cd9cad14f1d41b8a Mon Sep 17 00:00:00 2001 From: mrekucci Date: Fri, 30 Aug 2024 16:06:49 +0200 Subject: [PATCH] feat: introduce Geth archive node profile --- infrastructure/nomad/cluster.sh | 42 +++++++++++++++---- infrastructure/nomad/playbooks/deploy.yml | 15 +++++-- .../templates/jobs/mev-commit-geth.nomad.j2 | 4 ++ .../nomad/playbooks/variables/profiles.yml | 31 ++++++++++++++ 4 files changed, 80 insertions(+), 12 deletions(-) diff --git a/infrastructure/nomad/cluster.sh b/infrastructure/nomad/cluster.sh index afab4c8ae..9de5c6b90 100755 --- a/infrastructure/nomad/cluster.sh +++ b/infrastructure/nomad/cluster.sh @@ -17,11 +17,13 @@ profile_name="devnet" datadog_key="" l1_rpc_url="" otel_collector_endpoint_url="" +genesis_file_url="" +geth_bootnode_url="" help() { echo "Usage:" echo "$0 [init [--environment ] [--skip-certificates-setup] [--debug]]" - echo "$0 [deploy [version=HEAD] [--environment ] [--profile ] [--force-build-templates] [--no-logs-collection] [--datadog-key ] [--l1-rpc-url ] [--otel-collector-endpoint-url ] [--release] [--debug]]" + echo "$0 [deploy [version=HEAD] [--environment ] [--profile ] [--force-build-templates] [--no-logs-collection] [--datadog-key ] [--l1-rpc-url ] [--otel-collector-endpoint-url ] [--genesis-file-url ] [--geth-bootnode-url ] [--release] [--debug]]" echo "$0 [destroy [--backup] [--debug]]" echo "$0 --help" echo @@ -32,13 +34,15 @@ help() { echo " --debug Enable debug mode for detailed output." echo echo " deploy [version=HEAD] Deploy the specified artifact version (a git commit hash or an existing AWS S3 tag). If not specified or set to HEAD, a local build is triggered." - echo " --environment Specify the environment to use (default is devenv)." - echo " --profile Specify the profile to use (default is devnet)." + echo " --environment ] Specify the environment to use (default is devenv)." + echo " --profile ] Specify the profile to use (default is devnet)." echo " --force-build-templates Force the build of all job templates before deployment." echo " --no-logs-collection Disable the collection of logs from deployed jobs." - echo " --datadog-key Datadog API key, cannot be empty." - echo " --l1-rpc-url L1 RPC URL, cannot be empty." - echo " --otel-collector-endpoint-url OpenTelemetry Collector Endpoint URL, cannot be empty." + echo " --datadog-key ] Datadog API key, cannot be empty." + echo " --l1-rpc-url ] L1 RPC URL, cannot be empty." + echo " --otel-collector-endpoint-url ] OpenTelemetry Collector Endpoint URL, cannot be empty." + echo " --genesis-file-url ] URL to the genesis file, cannot be empty." + echo " --geth-bootnode-url ] URL to the Geth bootnode, cannot be empty." echo " --release It will ignore the specified deployment version and use the current HEAD tag as the build version." echo " --debug Enable debug mode for detailed output." echo @@ -70,8 +74,8 @@ help() { echo " Deploy with a specific version, environment, profile and force to build all job templates:" echo " $0 deploy v0.1.0 --environment devenv --profile testnet --force-build-templates" echo - echo " Deploy with a specific version, environment, profile in debug mode with disabled logs collection, Datadog API key, L1 RPC URL, and OpenTememetry Collector Endpoint URL:" - echo " $0 deploy v0.1.0 --environment devenv --profile testnet --no-logs-collection --datadog-key your_datadog_key --l1-rpc-url your_rpc_url --otel-collector-endpoint-url your_otel_url --debug" + echo " Deploy with a specific version, environment, profile in debug mode with disabled logs collection, Datadog API key, L1 RPC URL, OpenTelemetry Collector Endpoint URL, genesis file URL, and Geth bootnode URL:" + echo " $0 deploy v0.1.0 --environment devenv --profile testnet --no-logs-collection --datadog-key your_datadog_key --l1-rpc-url your_rpc_url --otel-collector-endpoint-url your_otel_url --genesis-file-url your_genesis_file_url --geth-bootnode-url your_geth_bootnode_url --debug" echo echo " Destroy all jobs but backup before do so:" echo " $0 destroy --backup --debug" @@ -81,7 +85,7 @@ help() { usage() { echo "Usage:" echo "$0 [init [--environment ] [--skip-certificates-setup] [--debug]]" - echo "$0 [deploy [version=HEAD] [--environment ] [--profile ] [--force-build-templates] [--no-logs-collection] [--datadog-key ] [--l1-rpc-url ] [--otel-collector-endpoint-url ] [--release] [--debug]]" + echo "$0 [deploy [version=HEAD] [--environment ] [--profile ] [--force-build-templates] [--no-logs-collection] [--datadog-key ] [--l1-rpc-url ] [--otel-collector-endpoint-url ] [--genesis-file-url ] [--geth-bootnode-url ] [--release] [--debug]]" echo "$0 [destroy [--backup] [--debug]]" echo "$0 --help" exit 1 @@ -229,6 +233,24 @@ parse_args() { usage fi fi + if [[ $# -gt 0 && $1 == "--genesis-file-url" ]]; then + if [[ $# -gt 1 && ! $2 =~ ^-- ]]; then + genesis_file_url="$2" + shift 2 + else + echo "Error: --genesis-file-url requires a value." + usage + fi + fi + if [[ $# -gt 0 && $1 == "--geth-bootnode-url" ]]; then + if [[ $# -gt 1 && ! $2 =~ ^-- ]]; then + geth_bootnode_url="$2" + shift 2 + else + echo "Error: --geth-bootnode-url requires a value." + usage + fi + fi if [[ $# -gt 0 && $1 == "--release" ]]; then release_flag=true shift @@ -290,6 +312,8 @@ main() { [[ -n "${datadog_key}" ]] && flags+=("--extra-vars" "datadog_key=${datadog_key}") [[ -n "${l1_rpc_url}" ]] && flags+=("--extra-vars" "l1_rpc_url=${l1_rpc_url}") [[ -n "${otel_collector_endpoint_url}" ]] && flags+=("--extra-vars" "otel_collector_endpoint_url=${otel_collector_endpoint_url}") + [[ -n "${genesis_file_url}" ]] && flags+=("--extra-vars" "genesis_file_url=${genesis_file_url}") + [[ -n "${geth_bootnode_url}" ]] && flags+=("--extra-vars" "geth_bootnode_url=${geth_bootnode_url}") [[ "${release_flag}" == true ]] && flags+=("--extra-vars" "release=true") ;; "${destroy_flag}") diff --git a/infrastructure/nomad/playbooks/deploy.yml b/infrastructure/nomad/playbooks/deploy.yml index de606e524..c73b748c1 100644 --- a/infrastructure/nomad/playbooks/deploy.yml +++ b/infrastructure/nomad/playbooks/deploy.yml @@ -8,6 +8,7 @@ release: false build_artifacts: false build_templates: false + genesis_file_url: "" otel_collector_endpoint_url: "" aws_s3_bucket: "primev-infrastructure-artifacts" @@ -523,10 +524,18 @@ ) | jq -c '.' > "{{ dist_dir }}/genesis_{{ environments[env].version }}.json" args: executable: bash - register: genesis_facts delegate_to: localhost run_once: true - when: build_artifacts + when: build_artifacts and genesis_file_url | trim | length == 0 + + - name: Fetch Genesis File + ansible.builtin.uri: + url: "{{ genesis_file_url }}" + dest: "{{ dist_dir }}/genesis_{{ environments[env].version }}.json" + return_content: no + delegate_to: localhost + run_once: true + when: build_artifacts and genesis_file_url | trim | length > 0 - name: Prepare launchmevcommit Script ansible.builtin.shell: | @@ -548,7 +557,7 @@ executable: bash delegate_to: localhost run_once: true - when: build_artifacts and env == 'devenv' + when: build_artifacts and env == 'devenv' and profile != 'archive' - name: Filter Artifacts for Upload ansible.builtin.find: diff --git a/infrastructure/nomad/playbooks/templates/jobs/mev-commit-geth.nomad.j2 b/infrastructure/nomad/playbooks/templates/jobs/mev-commit-geth.nomad.j2 index 8c5867dd5..b8c29c076 100644 --- a/infrastructure/nomad/playbooks/templates/jobs/mev-commit-geth.nomad.j2 +++ b/infrastructure/nomad/playbooks/templates/jobs/mev-commit-geth.nomad.j2 @@ -238,6 +238,9 @@ job "{{ job.name }}" { {% endif %} GETH_SYNC_MODE="{{ job.env['sync_mode'] }}" {% if job.env['type'] != 'bootnode' %} + {% if geth_bootnode_url is defined %} + BOOTNODE_ENDPOINT="{{ geth_bootnode_url }}" + {% else %} {%- raw %} {{- range nomadService "mev-commit-geth-bootnode1" }} {{- if contains "p2p" .Tags }} @@ -245,6 +248,7 @@ job "{{ job.name }}" { {{- end }} {{- end }} {% endraw %} + {% endif %} {% endif %} EOH destination = "secrets/.env" diff --git a/infrastructure/nomad/playbooks/variables/profiles.yml b/infrastructure/nomad/playbooks/variables/profiles.yml index 5467a0bca..336a34869 100644 --- a/infrastructure/nomad/playbooks/variables/profiles.yml +++ b/infrastructure/nomad/playbooks/variables/profiles.yml @@ -107,6 +107,30 @@ jobs: type: member sync_mode: snap + mev_commit_geth_archive_node: &mev_commit_geth_archive_node_job + name: mev-commit-geth-archive-node + template: mev-commit-geth.nomad.j2 + artifacts: + - *geth_artifact + count: 1 + ports: + - metrics: + to: 6060 + http: + static: 8565 + to: 8545 + ws: + static: 8566 + to: 8546 + p2p: + to: 30311 + env: + ip: 0.0.0.0 + public_ip: "{{ ansible_facts['default_ipv4']['address'] }}" + net_restrict: 0.0.0.0/0 + type: archive + sync_mode: full + contracts_deployer: &contracts_deployer_job name: contracts-deployer template: contracts-deployer.nomad.j2 @@ -632,3 +656,10 @@ profiles: - *mev_commit_oracle_job - *mev_commit_faucet_job - *datadog_agent_metrics_collector_job + + archive: + jobs: + - *artifacts_job + - *datadog_agent_logs_collector_job + - *otel_collector_job + - *mev_commit_geth_archive_node_job