From 03923a2927569704b7707b78e33d350966451715 Mon Sep 17 00:00:00 2001 From: Nicolas Ochem Date: Tue, 28 Nov 2023 21:59:32 -0800 Subject: [PATCH] add an option to override the network name for snapshot metadata (#614) * add an option to override the network name for snapshot metadata * fix tests * fix other test --- charts/tezos/templates/configs.yaml | 1 + charts/tezos/values.yaml | 6 +++++- test/charts/mainnet.expect.yaml | 1 + test/charts/mainnet2.expect.yaml | 1 + test/charts/private-chain.expect.yaml | 1 + utils/config-generator.py | 5 ++++- 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/charts/tezos/templates/configs.yaml b/charts/tezos/templates/configs.yaml index aeb9f9589..84cd1f07f 100644 --- a/charts/tezos/templates/configs.yaml +++ b/charts/tezos/templates/configs.yaml @@ -21,6 +21,7 @@ data: ROLLING_TARBALL_URL: "{{ .Values.rolling_tarball_url }}" ARCHIVE_TARBALL_URL: "{{ .Values.archive_tarball_url }}" PREFER_TARBALLS: "{{ .Values.prefer_tarballs }}" + SNAPSHOT_METADATA_NETWORK_NAME: "{{ .Values.snapshot_metadata_network_name }}" SNAPSHOT_SOURCE: "{{ .Values.snapshot_source }}" OCTEZ_VERSION: "{{ .Values.images.octez }}" NODE_GLOBALS: | diff --git a/charts/tezos/values.yaml b/charts/tezos/values.yaml index f8f5b0f94..55e3da0bc 100644 --- a/charts/tezos/values.yaml +++ b/charts/tezos/values.yaml @@ -360,6 +360,10 @@ snapshot_source: https://xtz-shots.io/tezos-snapshots.json # If you prefer tarballs, set to "true" below. prefer_tarballs: false +# In case the network name in the snapshot metadata does not correspond to the +# network_name configured in `node_config_network`, hardcode the value here. +# snapshot_metadata_network_name: "weeklynet" + # By default, tezos-k8s will attempt to download the right artifact from # `snapshot_source` set above. You can override and hard-code a snapshot URL # source below. When any of the below variables are set, `snapshot_source` above @@ -397,7 +401,7 @@ expected_proof_of_work: 26 ## - Specify the name of the network which must be recognized by the ## octez-node binary of the Octez image being used. ## - Pass a url that returns the config.json of the network. Example: -## "https://teztnets.xyz/mondaynet". It is helpful for running +## "https://teztnets.xyz/weeklynet". It is helpful for running ## testnets and shouldn't be needed in general. node_config_network: chain_name: mainnet diff --git a/test/charts/mainnet.expect.yaml b/test/charts/mainnet.expect.yaml index 6fc41d610..eeb830773 100644 --- a/test/charts/mainnet.expect.yaml +++ b/test/charts/mainnet.expect.yaml @@ -37,6 +37,7 @@ data: ROLLING_TARBALL_URL: "" ARCHIVE_TARBALL_URL: "" PREFER_TARBALLS: "false" + SNAPSHOT_METADATA_NETWORK_NAME: "" SNAPSHOT_SOURCE: "https://xtz-shots.io/tezos-snapshots.json" OCTEZ_VERSION: "tezos/tezos:v17.3" NODE_GLOBALS: | diff --git a/test/charts/mainnet2.expect.yaml b/test/charts/mainnet2.expect.yaml index ccc8c09b3..e3c380752 100644 --- a/test/charts/mainnet2.expect.yaml +++ b/test/charts/mainnet2.expect.yaml @@ -37,6 +37,7 @@ data: ROLLING_TARBALL_URL: "" ARCHIVE_TARBALL_URL: "" PREFER_TARBALLS: "false" + SNAPSHOT_METADATA_NETWORK_NAME: "" SNAPSHOT_SOURCE: "https://xtz-shots.io/tezos-snapshots.json" OCTEZ_VERSION: "tezos/tezos:v17.3" NODE_GLOBALS: | diff --git a/test/charts/private-chain.expect.yaml b/test/charts/private-chain.expect.yaml index 3d3b8fe1b..3c36edc32 100644 --- a/test/charts/private-chain.expect.yaml +++ b/test/charts/private-chain.expect.yaml @@ -130,6 +130,7 @@ data: ROLLING_TARBALL_URL: "" ARCHIVE_TARBALL_URL: "" PREFER_TARBALLS: "false" + SNAPSHOT_METADATA_NETWORK_NAME: "" SNAPSHOT_SOURCE: "" OCTEZ_VERSION: "tezos/tezos:v15-release" NODE_GLOBALS: | diff --git a/utils/config-generator.py b/utils/config-generator.py index 4d9fb2c1c..2c493162f 100755 --- a/utils/config-generator.py +++ b/utils/config-generator.py @@ -684,7 +684,10 @@ def create_node_config_json( def create_node_snapshot_config_json(history_mode): """Create this node's snapshot config""" - network_name = NETWORK_CONFIG.get("chain_name") + if os.environ.get("SNAPSHOT_METADATA_NETWORK_NAME"): + network_name = os.environ.get("SNAPSHOT_METADATA_NETWORK_NAME") + else: + network_name = NETWORK_CONFIG.get("chain_name") prefer_tarballs = os.environ.get("PREFER_TARBALLS", "").lower() in ( "true", "1",