-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the provided image for all tezos binaries (#177)
* Use the provided image for all tezos binaries To do this, we switch from making containers based on tezos/tezos:v8-release to making containers that either: 1. use the provided tezos image and execute a script which is passed in via the statefulset configuration, or 2. are not based on the tezos image and do not contain tezos binaries. These containers prepare configuration, files, etc., for the later containers. * Rename config-generator to "utils" and fold in wait-for-bootstrap As a first step on consolidating to fewer docker images, we fold wait-for-bootstrap into config-generator calling the result "utils". * Make utils/entrypoint.sh into a spawner of the other scripts. And fix a few things along the way. I think that I'll squash this into the previous commits before merging to the master branch. * Forgot to git add utils/config-generator.sh. * Rename file to correct place. * Make tezos-node also use an external script. This lets us put some debugging in there. * utils/Dockerfile: pin to python:3.8-alpine and streamline. * Various changes to get zerotier working (not the invite) The most interesting one here is that for some reason, zerotier races with tezos-node. If the latter wins, then it fails to bind to the p2p listen-address because zerotier hasn't yet setup the VPN. We solve this by restarting tezos-node a number of times on failure. We also sleep 3600 on tezos-node exit to give us a chance to get a shell on the node. We may want to consider this, though. * Fix zerotier invites... The issue was that the CHAIN_NAME env var wasn't percolating to the inviter and so the host was labeled _bootstrap. The invitee then looked for ${CHAIN_NAME}_bootstrap, which obviously wasn't there... * Eliminate spurious error. * Use Python 3.9 rather than 3.8. * Remove confusing comment.
- Loading branch information
Showing
29 changed files
with
361 additions
and
220 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
In this directory, please find a number of scripts that are used | ||
to start various components in the tezos docker images. | ||
|
||
These script snippets are not executed as files by /bin/sh, but rather | ||
as a single line passed in via -c. | ||
|
||
We also ask for the helm template system to be passed over the snippet | ||
before it is inserted into the chart. | ||
|
||
YAML ISSUES | ||
|
||
Because we are actually including this snippet into YAML as | ||
an indented blob, it is a requirement that the first character | ||
in the file is in column zero. | ||
|
||
TEMPLATING | ||
|
||
Because the templating system is used, you can use any of the | ||
features provided. Mostly, variable expansion, i.e. | ||
|
||
{{ .Values.protocol.command }} | ||
|
||
If you use braces within the file, you will have to escape them, | ||
though: | ||
|
||
{{ "{{" }} | ||
|
||
SCRIPT SIZE LIMIT | ||
|
||
Each OS has limit on the number of bytes that can be passed to | ||
a command to be executed. In some cases, this may be relatively | ||
small, but we should be able to assume that it's at least 64KB. | ||
So, be explicit, take care of all of the error cases, but do not | ||
write your great novel. | ||
|
||
In practice, you are unlikely to run into this limit, but it | ||
exists and so it must be mentioned. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
set -ex | ||
|
||
TEZ_VAR=/var/tezos | ||
TEZ_BIN=/usr/local/bin | ||
CLIENT_DIR="$TEZ_VAR/client" | ||
NODE_DIR="$TEZ_VAR/node" | ||
NODE_DATA_DIR="$TEZ_VAR/node/data" | ||
|
||
proto_command="{{ .Values.protocol.command }}" | ||
|
||
if [ "${DAEMON}" == "baker" ]; then | ||
extra_args="with local node $NODE_DATA_DIR" | ||
fi | ||
|
||
my_baker_account="$(cat /etc/tezos/baker-account )" | ||
|
||
CLIENT="$TEZ_BIN/tezos-client -d $CLIENT_DIR" | ||
CMD="$TEZ_BIN/tezos-$DAEMON-$proto_command -d $CLIENT_DIR" | ||
|
||
while ! $CLIENT rpc get chains/main/blocks/head; do | ||
sleep 5 | ||
done | ||
|
||
exec $CMD run ${extra_args} ${my_baker_account} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CLIENT="/usr/local/bin/tezos-client -A tezos-node-rpc -P 8732" | ||
|
||
until $CLIENT rpc get /version; do | ||
sleep 2 | ||
done | ||
|
||
echo /etc/tezos/parameters.json contains: | ||
echo ------------------------------------------------------------ | ||
cat /etc/tezos/parameters.json | ||
echo ------------------------------------------------------------ | ||
echo Activating chain: | ||
set -x | ||
$CLIENT -d /var/tezos/client -l --block \ | ||
genesis activate protocol \ | ||
{{ .Values.activation.protocol_hash }} \ | ||
with fitness -1 and key \ | ||
{{ .Values.node_config_network.activation_account_name }} \ | ||
and parameters /etc/tezos/parameters.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
echo "Writing custom configuration for public node" | ||
mkdir -p /etc/tezos/data | ||
|
||
# | ||
# This is my comment. | ||
|
||
/usr/local/bin/tezos-node config init \ | ||
--config-file /etc/tezos/data/config.json \ | ||
--data-dir /etc/tezos/data \ | ||
--network $CHAIN_NAME | ||
|
||
cat /etc/tezos/data/config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
set -ex | ||
|
||
bin_dir="/usr/local/bin" | ||
|
||
data_dir="/var/tezos" | ||
node_dir="$data_dir/node" | ||
node_data_dir="$node_dir/data" | ||
node="$bin_dir/tezos-node" | ||
snapshot_file=${node_dir}/chain.snapshot | ||
|
||
if [ -d ${node_data_dir}/context ]; then | ||
echo "Blockchain has already been imported, exiting" | ||
exit 0 | ||
fi | ||
|
||
${node} snapshot import ${snapshot_file} --data-dir ${node_data_dir} \ | ||
--network $CHAIN_NAME --config-file /etc/tezos/config.json | ||
find ${node_dir} | ||
rm -rvf ${snapshot_file} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
set -x | ||
|
||
set | ||
|
||
# | ||
# Not every error is fatal on start. In particular, with zerotier, | ||
# the listen-addr may not yet be bound causing tezos-node to fail. | ||
# So, we try a few times with increasing delays: | ||
|
||
for d in 1 1 5 10 20 60 120; do | ||
/usr/local/bin/tezos-node run \ | ||
--bootstrap-threshold 0 \ | ||
--config-file /etc/tezos/config.json | ||
sleep $d | ||
done | ||
|
||
# | ||
# Keep the container alive for troubleshooting on failures: | ||
|
||
sleep 3600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.