Medalla-related changes [skip ci] (#1419)

This commit is contained in:
Ștefan Talpalaru 2020-08-03 23:58:13 +02:00 committed by GitHub
parent df80071bcf
commit 7b5411a86e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 11 deletions

View File

@ -7,9 +7,6 @@ RUN apt-get -qq update \
&& apt-get -qq clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ARG NETWORK
ENV NETWORK=${NETWORK}
STOPSIGNAL SIGINT
COPY "entry_point.sh" "/root/"

View File

@ -2,7 +2,6 @@ SHELL := bash # the shell used internally by "make"
# These default settings can be overriden by exporting env variables
NETWORK ?= witti
IMAGE_TAG ?= testnet2
IMAGE_NAME ?= statusteam/nimbus_beacon_node:$(IMAGE_TAG)
@ -14,7 +13,6 @@ COMPUTER_SAYS_NO = { echo "I'm sorry, Dave. I'm afraid I can't do that."; exit 1
build:
@ DOCKER_BUILDKIT=1 \
docker build \
--build-arg="NETWORK=$(NETWORK)" \
-t $(IMAGE_NAME) \
--progress=plain \
.

View File

@ -24,13 +24,13 @@ From the "infra-nimbus" repo:
```text
git pull
make requirements
ansible-playbook ansible/nimbus.yml -i ansible/inventory/test -t beacon-node -u YOUR_USER -K -l nimbus-slaves[5:8]
ansible-playbook ansible/nimbus.yml -i ansible/inventory/test -t beacon-node -u YOUR_USER -K -l nimbus.test[6:9]
# faster way to pull the Docker image and recreate the containers (this also stops any running container)
ansible nimbus-slaves[5:8] -i ansible/inventory/test -u YOUR_USER -o -m shell -a "echo; cd /docker/beacon-node-testnet2-1; docker-compose --compatibility pull; docker-compose --compatibility up --no-start; echo '---'" | sed 's/\\n/\n/g'
ansible nimbus.test[6:9] -i ansible/inventory/test -u YOUR_USER -o -m shell -a "echo; cd /docker/beacon-node-testnet2; docker-compose --compatibility pull; docker-compose --compatibility up --no-start; echo '---'" | sed 's/\\n/\n/g'
# build beacon_node in an external volume
ansible nimbus-slaves[5:8] -i ansible/inventory/test -u YOUR_USER -o -m shell -a "echo; cd /docker/beacon-node-testnet2-1; docker-compose --compatibility run --rm beacon_node --build; echo '---'" | sed 's/\\n/\n/g'
ansible nimbus.test[6:9] -i ansible/inventory/test -u YOUR_USER -o -m shell -a "echo; cd /docker/beacon-node-testnet2; docker-compose --compatibility run --rm beacon_node --build; echo '---'" | sed 's/\\n/\n/g'
```
### create and copy validator keys
@ -52,7 +52,7 @@ From the nim-beacon-chain repo:
From the "infra-nimbus" repo:
```bash
ansible nimbus-slaves[5:8] -i ansible/inventory/test -u YOUR_USER -o -m shell -a "echo; cd /docker/beacon-node-testnet2-1; docker-compose --compatibility up -d; echo '---'" | sed 's/\\n/\n/g'
ansible nimbus.test[6:9] -i ansible/inventory/test -u YOUR_USER -o -m shell -a "echo; cd /docker/beacon-node-testnet2; docker-compose --compatibility up -d; echo '---'" | sed 's/\\n/\n/g'
```
### restarting the containers
@ -60,12 +60,20 @@ ansible nimbus-slaves[5:8] -i ansible/inventory/test -u YOUR_USER -o -m shell -a
Periodic rebuilds and restarts are implemented using Cron jobs on the servers:
```crontab
10 0,6,12,18 * * * PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin'; cd /docker/beacon-node-testnet2-1; docker-compose --compatibility run --rm --name beacon-node-testnet2-1-build-run beacon_node --build; docker-compose restart -t 60
0 0,6,12,18 * * * PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin'; cd /docker/beacon-node-testnet2; docker-compose --compatibility run --rm --name beacon-node-testnet2-build-run beacon_node --build; docker-compose restart -t 60
```
The same, using Ansible (not normally needed):
```bash
ansible nimbus-slaves[5:8] -i ansible/inventory/test -u YOUR_USER -o -m shell -a "echo; cd /docker/beacon-node-testnet2-1; docker-compose --compatibility run --rm --name beacon-node-testnet2-1-build-run beacon_node --build; docker-compose restart -t 60; echo '---'" | sed 's/\\n/\n/g'
ansible nimbus.test[6:9] -i ansible/inventory/test -u YOUR_USER -o -m shell -a "echo; cd /docker/beacon-node-testnet2; docker-compose --compatibility run --rm --name beacon-node-testnet2-build-run beacon_node --build; docker-compose restart -t 60; echo '---'" | sed 's/\\n/\n/g'
```
## Medalla
```bash
make -C docker/shared_testnet IMAGE_TAG=testnet3 push
cd ../infra-nimbus
ansible nimbus.test[0:5] -i ansible/inventory/test -u YOUR_USER -o -m shell -a "echo; cd /docker/beacon-node-testnet3; docker-compose --compatibility run --rm --name beacon-node-testnet3-build-run beacon_node --build; docker-compose restart -t 60; echo '---'" | sed 's/\\n/\n/g'
```

View File

@ -0,0 +1,38 @@
#!/bin/bash
set -e
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
GROUP=0
TOTAL=$(ls -d ../nimbus-private/medalla_deposits/validators/* | wc -l)
HOSTS=(
"master-01.aws-eu-central-1a.nimbus.test.statusim.net"
"node-01.aws-eu-central-1a.nimbus.test.statusim.net"
"node-02.aws-eu-central-1a.nimbus.test.statusim.net"
"node-03.aws-eu-central-1a.nimbus.test.statusim.net"
"node-04.aws-eu-central-1a.nimbus.test.statusim.net"
"node-05.aws-eu-central-1a.nimbus.test.statusim.net"
)
PER_GROUP=$(( TOTAL / ${#HOSTS[@]} ))
for HOST in "${HOSTS[@]}"; do
ssh ${HOST} "sudo rm -rf /docker/beacon-node-testnet3/data/nim-beacon-chain/build/data/shared_medalla_0/secrets"
ssh ${HOST} "sudo rm -rf /docker/beacon-node-testnet3/data/nim-beacon-chain/build/data/shared_medalla_0/validators"
for TARGET in "validators" "secrets"; do
DIR_NO=0
ls -d ../nimbus-private/medalla_deposits/${TARGET}/* | while read DIR; do
if [[ $DIR_NO -ge $((GROUP * PER_GROUP)) && $DIR_NO -lt $(( (GROUP + 1) * PER_GROUP )) ]]; then
rsync -a -zz --rsync-path="sudo rsync" "$DIR" ${HOST}:/docker/beacon-node-testnet3/data/nim-beacon-chain/build/data/shared_medalla_0/${TARGET}/
elif [[ $(( GROUP + 1 )) == ${#HOSTS[@]} && $DIR_NO -ge $(( (GROUP + 1) * PER_GROUP )) ]]; then
# extra validators from the integer division remainder
rsync -a -zz --rsync-path="sudo rsync" "$DIR" ${HOST}:/docker/beacon-node-testnet3/data/nim-beacon-chain/build/data/shared_medalla_0/${TARGET}/
fi
DIR_NO=$((DIR_NO + 1))
done
done
GROUP=$((GROUP + 1))
ssh ${HOST} "sudo chown -R dockremap:dockremap /docker/beacon-node-testnet3/data/nim-beacon-chain/build/data/shared_medalla_0/secrets"
ssh ${HOST} "sudo chown -R dockremap:dockremap /docker/beacon-node-testnet3/data/nim-beacon-chain/build/data/shared_medalla_0/validators"
done