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

snapshot engine: fix #416 (remove the hardcoding) and #433 (add url in metadata) #438

Merged
merged 10 commits into from
May 6, 2022
Merged
7 changes: 5 additions & 2 deletions charts/snapshotEngine/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ data:
NAMESPACE: {{ $.Release.Namespace }}
IMAGE_NAME: {{ $.Values.tezos_k8s_images.snapshotEngine }}
TEZOS_IMAGE: {{ $.Values.images.octez }}
SNAPSHOT_MARKDOWN_TEMPLATE_URL: {{ $.Values.snapshotMarkdownTemplateUrl }}
SNAPSHOT_MARKDOWN_TEMPLATE: {{ $.Values.snapshotMarkdownTemplate }}
JEKYLL_CONFIG: {{ $.Values.jekyllConfig }}
JEKYLL_REMOTE_THEME_REPOSITORY: {{ $.Values.jekyllRemoteThemeRepository }}
SNAPSHOT_WEBSITE_DOMAIN_NAME: {{ $.Values.snapshotWebsiteDomainName }}
SERVICE_ACCOUNT: {{ $.Values.service_account }}
RESTORED_STORAGE_INIT_TIME: {{ $.Values.restoredStorageInitTime }}
DISABLE_STORAGE_INIT_TIME: {{ $.Values.disableStorageInitTime | quote }}
kind: ConfigMap
metadata:
name: snapshot-configmap
namespace: {{ $.Release.Namespace }}
namespace: {{ $.Release.Namespace }}
29 changes: 22 additions & 7 deletions charts/snapshotEngine/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,29 @@ nodes:
history_mode: rolling
target_volume: var-volume

# snapshot website domain name
# Example:
# snapshotWebsiteDomainName: xtz-shots.io
snapshotWebsiteDomainName: ""

# snapshotEngine generates static webpages to accompany the generated
# artifacts. They are rendered by jekyll.
# Below specify the URL for the source markdown file template to render for
# every individual artifact.
# It will be rendered based on metadata generated by the snapshot engine.
# See an example at:
# https://github.com/oxheadalpha/xtz-shots-website/blob/master/snapshot.md
snapshotMarkdownTemplateUrl: ""
# See an example jekyll template at:
# https://github.com/oxheadalpha/xtz-shots-website/
# 3 parameters need to be passed:
# * jekyllRemoteThemeRepository: the github repository, in format organization/reponame
# * snapshotMarkdownTemplate: the URL for the source markdown file template
# to render for every individual artifact.
# It will be rendered based on metadata generated by the snapshot engine.
# * jekyllConfig: the jekyll _config.yml to be used
#
# Example:
# jekyllRemoteThemeRepository: oxheadalpha/xtz-shots-website
# snapshotMarkdownTemplate: https://raw.githubusercontent.com/oxheadalpha/xtz-shots-website/master/snapshot.md
# jekyllConfig: https://raw.githubusercontent.com/oxheadalpha/xtz-shots-website/master/_config.yml
jekyllRemoteThemeRepository: ""
snapshotMarkdownTemplate: ""
jekyllConfig: ""

# When setting up the CSI driver in Kubernetes to create a snapshottable storage class
# you will have also created and named a volumeSnapshotClass that will be used in this value.
Expand All @@ -70,4 +85,4 @@ volumeSnapClass: ""
restoredStorageInitTime: 2m

# We also provide the ability to disable the time limit for debugging purposes.
disableStorageInitTime: "false"
disableStorageInitTime: "false"
13 changes: 3 additions & 10 deletions snapshotEngine/mainJob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,9 @@ spec:
env:
- name: HISTORY_MODE
value: ""
- name: NAMESPACE
valueFrom:
configMapKeyRef:
name: snapshot-configmap
key: NAMESPACE
- name: SNAPSHOT_MARKDOWN_TEMPLATE_URL
valueFrom:
configMapKeyRef:
name: snapshot-configmap
key: SNAPSHOT_MARKDOWN_TEMPLATE_URL
envFrom:
- configMapRef:
name: snapshot-configmap
restartPolicy: Never
volumes:
- name: persistent-storage
Expand Down
60 changes: 0 additions & 60 deletions snapshotEngine/snapshot-website-base/_config.yml

This file was deleted.

26 changes: 21 additions & 5 deletions snapshotEngine/zip-and-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BLOCK_TIMESTAMP=$(cat /"${HISTORY_MODE}"-snapshot-cache-volume/BLOCK_TIMESTAMP)
TEZOS_VERSION=$(cat /"${HISTORY_MODE}"-snapshot-cache-volume/TEZOS_VERSION)
NETWORK="${NAMESPACE%%-*}"

S3_BUCKET="${NETWORK}.xtz-shots.io"
S3_BUCKET="${NETWORK}.${SNAPSHOT_WEBSITE_DOMAIN_NAME}"

cd /

Expand Down Expand Up @@ -145,6 +145,7 @@ if [ "${HISTORY_MODE}" = archive ]; then
--arg BLOCK_HEIGHT "${BLOCK_HEIGHT}" \
--arg BLOCK_TIMESTAMP "${BLOCK_TIMESTAMP}" \
--arg ARCHIVE_TARBALL_FILENAME "${ARCHIVE_TARBALL_FILENAME}" \
--arg URL "https://${S3_BUCKET}/${ARCHIVE_TARBALL_FILENAME}" \
--arg SHA256 "${SHA256}" \
--arg FILESIZE_BYTES "${FILESIZE_BYTES}" \
--arg FILESIZE "${FILESIZE}" \
Expand All @@ -158,6 +159,7 @@ if [ "${HISTORY_MODE}" = archive ]; then
"block_timestamp": $BLOCK_TIMESTAMP,
"filename": $ARCHIVE_TARBALL_FILENAME,
"sha256": $SHA256,
"url": $URL,
"filesize_bytes": $FILESIZE_BYTES,
"filesize": $FILESIZE,
"tezos_version": $TEZOS_VERSION,
Expand Down Expand Up @@ -331,6 +333,7 @@ if [ "${HISTORY_MODE}" = rolling ]; then
--arg BLOCK_HEIGHT "$BLOCK_HEIGHT" \
--arg BLOCK_TIMESTAMP "$BLOCK_TIMESTAMP" \
--arg ROLLING_TARBALL_FILENAME "$ROLLING_TARBALL_FILENAME" \
--arg URL "https://${S3_BUCKET}/${ROLLING_TARBALL_FILENAME}" \
--arg SHA256 "$SHA256" \
--arg FILESIZE_BYTES "$FILESIZE_BYTES" \
--arg FILESIZE "$FILESIZE" \
Expand All @@ -343,6 +346,7 @@ if [ "${HISTORY_MODE}" = rolling ]; then
"block_height": $BLOCK_HEIGHT,
"block_timestamp": $BLOCK_TIMESTAMP,
"filename": $ROLLING_TARBALL_FILENAME,
"url": $URL,
"sha256": $SHA256,
"filesize_bytes": $FILESIZE_BYTES,
"filesize": $FILESIZE,
Expand Down Expand Up @@ -469,6 +473,7 @@ if [ "${HISTORY_MODE}" = rolling ]; then
--arg BLOCK_HEIGHT "$BLOCK_HEIGHT" \
--arg BLOCK_TIMESTAMP "$BLOCK_TIMESTAMP" \
--arg ROLLING_SNAPSHOT_FILENAME "$ROLLING_SNAPSHOT_FILENAME" \
--arg URL "https://${S3_BUCKET}/${ROLLING_SNAPSHOT_FILENAME}" \
--arg SHA256 "$SHA256" \
--arg FILESIZE_BYTES "$FILESIZE_BYTES" \
--arg FILESIZE "$FILESIZE" \
Expand All @@ -481,6 +486,7 @@ if [ "${HISTORY_MODE}" = rolling ]; then
"block_height": $BLOCK_HEIGHT,
"block_timestamp": $BLOCK_TIMESTAMP,
"filename": $ROLLING_SNAPSHOT_FILENAME,
"url": $URL,
"filesize_bytes": $FILESIZE_BYTES,
"filesize": $FILESIZE,
"sha256": $SHA256,
Expand Down Expand Up @@ -532,7 +538,7 @@ fi
# Container-specific requirement
cd /srv/jekyll || exit

# Copy config and gemfile to current dir
# Copy Gemfile and Gemfile.lock to current dir
cp /snapshot-website-base/* .

# Grab latest metadata and put in _data
Expand All @@ -548,17 +554,27 @@ jq -n \
}' > _data/tezos_metadata.json

# Grab liquid-templated chain website page
curl -o index.md "${SNAPSHOT_MARKDOWN_TEMPLATE_URL}"
curl -o index.md "${SNAPSHOT_MARKDOWN_TEMPLATE}"

# Update chain name for page title using variable
sed -i'' -e 's/${NETWORK}/'"${NETWORK}"'/g' index.md

# Grab Jekyll config
curl -o _config.yml "${JEKYLL_CONFIG}"

# Add remote theme to config
cat <<EOF >> _config.yml
remote_theme: ${JEKYLL_REMOTE_THEME_REPOSITORY}
plugins:
- jekyll-remote-theme
EOF

Comment on lines +566 to +571
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't leave a comment on line 541 as it isn't part of the diff, but config should be removed from the comment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry i missed line 575 also. has xtz-shots.io.

chown -R jekyll:jekyll ./*
bundle exec jekyll build

# Upload chain page (index.html and assets for NETWORK.xtz-shots.io) to root of website bucket
# Upload chain page (index.html and assets) to root of website bucket
if ! aws s3 cp _site/ s3://"${S3_BUCKET}" --recursive --include "*"; then
printf "%s Website Build & Deploy : Error uploading site to S3.\n" "$(date "+%Y-%m-%d %H:%M:%S" "$@")"
else
printf "%s Website Build & Deploy : Sucessfully uploaded website to S3.\n" "$(date "+%Y-%m-%d %H:%M:%S" "$@")"
fi
fi