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

make hard-coded identity work when snapshot is being imported #405

Merged
merged 3 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions utils/config-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,11 @@ def import_keys(all_accounts):
def create_node_identity_json():
identity_file_path = f"{DATA_DIR}/identity.json"
path = Path(identity_file_path)
nicolasochem marked this conversation as resolved.
Show resolved Hide resolved
if path.exists() and path.stat().st_size > 0:
return

# Manually create the data directory and identity.json, and give the
# same dir/file permissions that tezos gives when it creates them.
print("\nWriting identity.json file from the instance config")
print(f"Node id: {NODE_IDENTITIES.get(MY_POD_NAME)['peer_id']}")

os.makedirs(DATA_DIR, 0o700, exist_ok=True)
with open(
Expand All @@ -443,6 +442,7 @@ def create_node_identity_json():
nogroup = getgrnam("nogroup").gr_gid
chown(DATA_DIR, user=100, group=nogroup)
chown(identity_file_path, user=100, group=nogroup)
print(f"Identity file written at {identity_file_path}")


#
Expand Down
4 changes: 2 additions & 2 deletions utils/snapshot-downloader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ if [ -n "$snapshot_url" ] && [ -n "$tarball_url" ]; then
echo "ERROR: Either only a snapshot or tarball url may be specified per Tezos node history mode."
fi

rm -rfv "$node_data_dir"
# We are inporting a tarball or snapshot, first we remove everything execpt identity.json
find $node_data_dir ! -name 'identity.json' -type f -exec rm -vf {} +
nicolasochem marked this conversation as resolved.
Show resolved Hide resolved
mkdir -p "$node_data_dir"

if [ -n "$snapshot_url" ]; then
Expand All @@ -61,7 +62,6 @@ if [ -n "$snapshot_url" ]; then
elif [ -n "$tarball_url" ]; then
echo "Downloading and extracting tarball from $tarball_url"
curl -LfsS "$tarball_url" | lz4 -d | tar -x -C "$data_dir"
rm -fv "$node_data_dir/identity.json"
fi

chown -R 100 "$data_dir"
Expand Down