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

fix(heimdall): update snapshot download #440

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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 changes: 1 addition & 1 deletion charts/heimdall/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.2.4
version: 1.2.5

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 2 additions & 2 deletions charts/heimdall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Deploy and scale [Heimdall](https://github.com/maticnetwork/heimdall) inside Kubernetes with ease

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) ![Version: 1.2.4](https://img.shields.io/badge/Version-1.2.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.10](https://img.shields.io/badge/AppVersion-1.0.10-informational?style=flat-square)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) ![Version: 1.2.5](https://img.shields.io/badge/Version-1.2.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.10](https://img.shields.io/badge/AppVersion-1.0.10-informational?style=flat-square)

## Features

Expand Down Expand Up @@ -54,7 +54,7 @@ We do not recommend that you upgrade the application by overriding `image.tag`.
| heimdall.config.ethRpcUrl | Ethereum RPC address | string | `""` |
| heimdall.config.extraArgs | Additional CLI arguments to pass to Heimdall | list | `[]` |
| heimdall.config.fromSnapshot.enabled | Enable initialising Heimdall from a remote Snapshot | bool | `false` |
| heimdall.config.fromSnapshot.snapshotUrl | URL to snapshot to download and extract, see [here](https://snapshots.matic.today) | string | `nil` |
| heimdall.config.fromSnapshot.snapshotUrl | URL to snapshot to download and extract, see [here](https://publicnode.com/snapshots#polygon) | string | `nil` |
| heimdall.config.logLevel | Log level setup | string | `"main:info,state:info,*:error"` |
| heimdall.config.logsType | Logs format | string | `"json"` |
| heimdall.config.metrics.enabled | Enable metrics | bool | `true` |
Expand Down
57 changes: 26 additions & 31 deletions charts/heimdall/templates/heimdall/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,17 @@ spec:
configMap:
name: {{ include "heimdall.fullname" . }}-{{ $componentName }}
initContainers:
- name: {{ $componentName }}-init
- name: {{ $componentName }}-init-config
image: "{{ $values.image.repository }}:{{ $values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ $values.image.pullPolicy }}
# securityContext:
# readOnlyRootFilesystem: false
# capabilities:
# drop:
# - ALL
# command: ["sh", "-c", "HEIMDALL_DIR=/storage /root/heimdall/docker/entrypoint.sh start"]
command:
- sh
- -c
- |
set -ex

HEIMDALLD_HOME="/storage"

# If config hasn't been boostrapped already, do it
# If config hasn't been bootstrapped already, do it
if [ ! -f "$HEIMDALLD_HOME/config/config.toml" ]; then
# Write out init config for Heimdall
heimdalld --home $HEIMDALLD_HOME init
fi

Expand All @@ -87,15 +78,6 @@ spec:
else
sed -iE "s#^prometheus \?=.*#prometheus = false#" config.toml
fi

# If enabled and snapshot URL has been provided, bootstrap snapshot
if [ "${BOOTSTRAP}" = 1 ] && [ "${SNAPSHOT_URL}" != "" ]; then
if [ ! -f "$HEIMDALLD_HOME/from_snapshot" ] || [ "$(cat $HEIMDALLD_HOME/from_snapshot)" != "${SNAPSHOT_URL}" ]; then
mkdir -p ${HEIMDALLD_HOME}/data
wget -c "${SNAPSHOT_URL}" -O - | tar -xz -C ${HEIMDALLD_HOME}/data
echo "${SNAPSHOT_URL}" > ${HEIMDALLD_HOME}/from_snapshot
fi
fi
volumeMounts:
- name: storage
mountPath: /storage
Expand All @@ -112,19 +94,32 @@ spec:
- name: METRICS_PORT
value: {{ index $values.service.ports "http-metrics" | quote }}
{{- end }}
{{- if $values.config.fromSnapshot.enabled }}
- name: BOOTSTRAP
value: "1"

{{- if and $values.config.fromSnapshot.enabled $values.config.fromSnapshot.snapshotUrl }}
- name: {{ $componentName }}-init-snapshot
## TODO: update tag
image: ghcr.io/graphops/docker-builds/init-stream-download@sha256:acbe5bff3b273b6e56b7aad20e8368ab9ddb091250b744e41ad66d6e7c2d0901
command:
- sh
- -c
- |
set -ex
HEIMDALLD_HOME="/storage"
# If enabled and snapshot URL has been provided, bootstrap snapshot
if [ ! -f "$HEIMDALLD_HOME/from_snapshot" ] || [ "$(cat $HEIMDALLD_HOME/from_snapshot)" != "${SNAPSHOT_URL}" ]; then
mkdir -p ${HEIMDALLD_HOME}/data
wget -c "${SNAPSHOT_URL}" -O snapshot.tar.lz4 || { echo "Download failed. Exiting."; exit 1; }
lz4 -d snapshot.tar.lz4 snapshot.tar || { echo "Decompression failed. Exiting."; exit 1; }
tar -xvf snapshot.tar -C ${HEIMDALLD_HOME}/data || { echo "Extraction failed. Exiting."; exit 1; }
echo "${SNAPSHOT_URL}" > ${HEIMDALLD_HOME}/from_snapshot
fi
volumeMounts:
- name: storage
mountPath: /storage
env:
- name: SNAPSHOT_URL
value: {{ $values.config.fromSnapshot.snapshotUrl }}
{{- end }}
{{- with $values.env }}
{{- range $key, $val := .}}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
{{- end }}

{{- end }}
containers:
- name: {{ $componentName }}
image: "{{ $values.image.repository }}:{{ $values.image.tag | default .Chart.AppVersion }}"
Expand Down
2 changes: 1 addition & 1 deletion charts/heimdall/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ heimdall:
fromSnapshot:
# -- Enable initialising Heimdall from a remote Snapshot
enabled: false
# -- URL to snapshot to download and extract, see [here](https://snapshots.matic.today)
# -- URL to snapshot to download and extract, see [here](https://publicnode.com/snapshots#polygon)
snapshotUrl:

# -- Options for Heimdall rest-server sidecar
Expand Down