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

chore: replace old binary/repo references #241

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,035 changes: 1,188 additions & 847 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ name="testnet-deploy"

[dependencies]
alloy = { version = "0.5.3", default-features = false, features = ["signers"] }
ant-releases = { git = "https://github.com/jacderida/ant-releases.git", branch = "chore-rename_binaries" }
ant-service-management = { git = "https://github.com/maidsafe/autonomi.git", branch = "main" }
async-recursion = "1.0.4"
aws-config = "0.56.0"
aws-sdk-s3 = "0.29.0"
Expand All @@ -32,6 +34,9 @@ libp2p = { version = "0.54.1", features = [] }
log = "0.4"
indicatif = "0.17.3"
inquire = "0.6.2"
# watch out updating this, protoc compiler needs to be installed on all build systems
# arm builds + musl are very problematic
prost = { version = "0.9" }
rand = "0.8.5"
rayon = "1.8.0"
regex = "1.9.5"
Expand All @@ -40,18 +45,13 @@ sha2 = "0.10.7"
semver = { version = "1.0.20", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "~1.0.108"
sn_service_management = "~0.2.8"
sn-releases = "0.3.1"
thiserror = "1.0.23"
tar = "0.4"
tempfile = "3.8.0"
tokio = { version = "1.26", features = ["full"] }
tokio-stream = "0.1.14"
walkdir = "~2.5.0"
# watch out updating this, protoc compiler needs to be installed on all build systems
# arm builds + musl are very problematic
prost = { version = "0.9" }
tonic = { version = "0.6.2" }
walkdir = "~2.5.0"

[dev-dependencies]
httpmock = "0.6"
8 changes: 4 additions & 4 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@ build-evm-node-image:
build.pkr.hcl
)

build-staging-bootstrap-image:
build-bootstrap-image:
#!/usr/bin/env bash
(
cd resources/packer/node
packer init .
packer build -var 'size=s-1vcpu-2gb' node.pkr.hcl
)

build-staging-node-image:
build-node-image:
#!/usr/bin/env bash
(
cd resources/packer/node
packer init .
packer build -var 'size=s-2vcpu-4gb' node.pkr.hcl
)

build-staging-uploader-image:
build-uploader-image:
#!/usr/bin/env bash
(
cd resources/packer/node
packer init .
packer build -var 'size=s-2vcpu-4gb' node.pkr.hcl
)

build-prod-nat-gateway-image:
build-nat-gateway-image:
#!/usr/bin/env bash
(
cd resources/packer/node
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
- name: fetch node manager inventory from remote machines
- name: fetch antctl inventory from remote machines
hosts: all
ignore_unreachable: yes
max_fail_percentage: 10
tasks:
- name: check if node registry file exists
stat:
path: "/var/safenode-manager/node_registry.json"
path: "/var/antctl/node_registry.json"
register: file_stat

- name: fetch inventory file
fetch:
src: "/var/safenode-manager/node_registry.json"
src: "/var/antctl/node_registry.json"
dest: "{{dest}}"
flat: no
validate_checksum: no
Expand Down
14 changes: 4 additions & 10 deletions resources/ansible/build.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
---
# We always build the faucet binary, but safenode only applies for using a custom branch.
- name: build binaries
hosts: all
become: False
roles:
- {
role: build_safe_network_binary,
bin_name: "autonomi",
bin_name: "ant",
when: custom_bin == "true"
}
- {
role: build_safe_network_binary,
bin_name: "safenode",
bin_name: "antnode",
when: custom_bin == "true"
}
- {
role: build_safe_network_binary,
bin_name: "safenode_rpc_client",
bin_name: "antctl",
when: custom_bin == "true"
}
- {
role: build_safe_network_binary,
bin_name: "safenode-manager",
when: custom_bin == "true"
}
- {
role: build_safe_network_binary,
bin_name: "safenodemand",
bin_name: "antctld",
when: custom_bin == "true"
}
6 changes: 3 additions & 3 deletions resources/ansible/cleanup_logs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
tasks:
- name: remove rotated logs
shell: |
for file in $(find /mnt/safenode-storage/log/safenode/ -name "*.gz"); do
for file in $(find /mnt/antnode-storage/log/antnode/ -name "*.gz"); do
rm $file
done

- name: setup cron job to remove rotated logs every 10 minutes
ansible.builtin.cron:
name: "cleanup_logs"
minute: "*/10"
job: "find /mnt/safenode-storage/log/safenode/ -name \"*.gz\" -exec rm {} \\;"
job: "find /mnt/antnode-storage/log/antnode/ -name \"*.gz\" -exec rm {} \\;"
state: present
when: setup_cron == "true"
when: setup_cron == "true"
11 changes: 9 additions & 2 deletions resources/ansible/create_node_image.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
---
- name: build a custom node image
hosts: all
become: False
become: True
roles:
- role: prerequisites
become: True
- role: filebeat
# Right now we are in a situation where we don't want Telegraf to be started automatically because
# we don't want metrics with new names to be forwarded to the existing production infrastructure.
tasks:
- name: stop telegraf
become: True
ansible.builtin.systemd:
name: telegraf
state: stopped
enabled: no
4 changes: 2 additions & 2 deletions resources/ansible/evm_nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
max_fail_percentage: 10
ignore_unreachable: yes
roles:
- safe_user
- ant_user
- evm_node
tasks:
# Something is wrong with the journal service on Ubuntu that causes no
Expand All @@ -16,4 +16,4 @@
ansible.builtin.systemd:
name: systemd-journald
state: restarted
enabled: yes
enabled: yes
4 changes: 2 additions & 2 deletions resources/ansible/genesis_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
vars:
is_genesis: True
roles:
- role: safe_user
- role: ant_user
become: True
- role: attach_volume
become: True
Expand All @@ -28,5 +28,5 @@
{ name: "{{ node_data_mount_path }}", owner: "root", group: "root", mode: 0755 },
when: provider == "aws"
}
- node-manager
- antctl
- genesis-node
44 changes: 12 additions & 32 deletions resources/ansible/nodes.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
---
- name: copy logstash certificate to nodes
hosts: all
become: False
max_fail_percentage: 10
ignore_unreachable: yes
tasks:
- name: copy public logstash certificate to node
copy:
src: logstash-{{ logstash_stack_name }}-public.crt
dest: /tmp/logstash-{{ logstash_stack_name }}-public.crt
mode: 0644
when: logstash_stack_name is defined and logstash_stack_name | length > 0

- name: deploy safenode to remaining nodes
- name: deploy antnode to remaining nodes
hosts: all
become: False
max_fail_percentage: 10
ignore_unreachable: yes
vars:
is_genesis: False
safenode_rpc_client_archive_filename: safenode_rpc_client-latest-x86_64-unknown-linux-musl.tar.gz
safenode_rpc_client_archive_url: https://sn-node-rpc-client.s3.eu-west-2.amazonaws.com/{{ safenode_rpc_client_archive_filename }}
roles:
- role: safe_user
- role: ant_user
become: True
- role: attach_volume
become: True
Expand All @@ -34,7 +19,7 @@
{ name: "{{ node_data_mount_path }}", owner: "root", group: "root", mode: 0755 },
when: provider == "aws"
}
- node-manager
- antctl
- {
role: private_node,
become: True,
Expand All @@ -54,20 +39,15 @@
name: systemd-journald
state: restarted
enabled: yes
# The RPC client is setup on all nodes for use with the metrics solution
- name: get the latest version or a custom build of the RPC client
ansible.builtin.get_url:
url: "{{ safenode_rpc_client_archive_url }}"
dest: /tmp/{{ safenode_rpc_client_archive_filename }}
- name: extract the RPC client binary to /usr/local/bin
become: True
ansible.builtin.unarchive:
src: "/tmp/{{ safenode_rpc_client_archive_filename }}"
dest: /usr/local/bin
remote_src: True
- name: restart telegraf
# - name: restart telegraf
# become: True
# ansible.builtin.systemd:
# name: telegraf
# state: restarted
# enabled: yes
- name: stop telegraf
become: True
ansible.builtin.systemd:
name: telegraf
state: restarted
enabled: yes
state: stopped
enabled: no
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
- name: user for running node
ansible.builtin.user:
name: safe
name: ant
shell: /bin/bash

- name: create .ssh directory for safe user
- name: create .ssh directory for ant user
ansible.builtin.file:
path: /home/safe/.ssh
owner: safe
group: safe
path: /home/ant/.ssh
owner: ant
group: ant
state: directory
mode: '0755'

# This is necessary for the logstash service, which runs as the logstash user, to
# read the log files under /home/safe/.local/share/safe/node.
# read the log files under /home/ant/.local/share/ant/node.
- name: make home directory accessible for logstash user
ansible.builtin.file:
path: /home/safe
path: /home/ant
mode: '0755'

# This is a bit of a hack, but it allows the `safe` user to have SSH access using the same
# This is a bit of a hack, but it allows the `ant` user to have SSH access using the same
# authorized_keys, which is useful for running utility scripts.
- name: create .ssh directory for safe user
- name: create .ssh directory for ant user
ansible.builtin.file:
path: /home/safe/.ssh
owner: safe
group: safe
path: /home/ant/.ssh
owner: ant
group: ant
state: directory
mode: '0755'
when: provider == "digital-ocean"

- name: copy authorized_keys to safe user
- name: copy authorized_keys to ant user
ansible.builtin.copy:
src: /root/.ssh/authorized_keys
dest: /home/safe/.ssh/authorized_keys
owner: safe
group: safe
dest: /home/ant/.ssh/authorized_keys
owner: ant
group: ant
remote_src: true
mode: '0600'
when: provider == "digital-ocean"
9 changes: 9 additions & 0 deletions resources/ansible/roles/antctl/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
public_rpc: False
node_rpc_ip: "127.0.0.1"
node_instance_count: 20
binary_dir: /usr/local/bin
antctl_archive_filename: antctl-latest-x86_64-unknown-linux-musl.tar.gz
antctl_archive_url: https://antctl.s3.eu-west-2.amazonaws.com/{{ antctl_archive_filename }}
antctld_archive_filename: antctld-latest-x86_64-unknown-linux-musl.tar.gz
antctld_archive_url: https://antctld.s3.eu-west-2.amazonaws.com/{{ antctld_archive_filename }}
52 changes: 52 additions & 0 deletions resources/ansible/roles/antctl/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
- name: check if antctl binary exists
ansible.builtin.stat:
path: "{{ binary_dir}}/antctl"
register: antctl_binary

- name: get the private IP for the instance
set_fact:
node_rpc_ip: "{{ instance_facts.instances[0].network_interfaces[0].private_ip_address }}"
when: provider == "aws" and public_rpc and not antctl_binary.stat.exists

- name: use the public IP as the RPC address on DO
set_fact:
node_rpc_ip: "{{ ansible_host }}"
when: provider == "digital-ocean" and public_rpc and not antctl_binary.stat.exists

- name: download the antctl binary
ansible.builtin.get_url:
url: "{{ antctl_archive_url }}"
dest: /tmp/{{ antctl_archive_filename }}
when: not antctl_binary.stat.exists

- name: extract the antctl binary to /usr/local/bin
become: True
ansible.builtin.unarchive:
src: "/tmp/{{ antctl_archive_filename }}"
dest: "{{ binary_dir }}"
remote_src: True
when: not antctl_binary.stat.exists

- name: download the antctld binary
ansible.builtin.get_url:
url: "{{ antctld_archive_url }}"
dest: /tmp/{{ antctld_archive_filename }}
when: not antctl_binary.stat.exists

- name: extract the antctld binary to /tmp/antctld
become: True
ansible.builtin.unarchive:
src: "/tmp/{{ antctld_archive_filename }}"
dest: /tmp/
remote_src: True
when: not antctl_binary.stat.exists

- name: add antctld
become: true
command: antctl -v daemon add --address {{ node_rpc_ip }} --path /tmp/antctld
when: not antctl_binary.stat.exists

- name: start antctld
become: true
command: antctl -v daemon start
Loading
Loading