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

feat(zstd snapshots): Update fullnode snapshot restore script to include tar.zst download a… #414

Merged
merged 6 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.9.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down
7 changes: 4 additions & 3 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5,190 changes: 2,581 additions & 2,609 deletions config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml

Large diffs are not rendered by default.

213 changes: 110 additions & 103 deletions config/crd/bases/cosmos.strange.love_scheduledvolumesnapshots.yaml

Large diffs are not rendered by default.

6,466 changes: 3,111 additions & 3,355 deletions config/crd/bases/cosmos.strange.love_statefuljobs.yaml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
Expand Down
23 changes: 14 additions & 9 deletions internal/fullnode/pod_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,11 @@ func (b PodBuilder) WithOrdinal(ordinal int32) PodBuilder {
}

const (
workDir = "/home/operator"
tmpDir = workDir + "/.tmp"
tmpConfigDir = workDir + "/.config"
infraToolImage = "ghcr.io/strangelove-ventures/infra-toolkit:v0.0.1"
workDir = "/home/operator"
tmpDir = workDir + "/.tmp"
tmpConfigDir = workDir + "/.config"
infraToolImage = "ghcr.io/strangelove-ventures/infra-toolkit"
infraToolVersion = "v0.1.6"

// Necessary for statesync
systemTmpDir = "/tmp"
Expand All @@ -339,6 +340,10 @@ func envVars(crd *cosmosv1.CosmosFullNode) []corev1.EnvVar {
}
}

func resolveInfraToolImage() string {
return fmt.Sprintf("%s:%s", infraToolImage, infraToolVersion)
}

func initContainers(crd *cosmosv1.CosmosFullNode, moniker string) []corev1.Container {
tpl := crd.Spec.PodTemplate
binary := crd.Spec.ChainSpec.Binary
Expand All @@ -353,7 +358,7 @@ func initContainers(crd *cosmosv1.CosmosFullNode, moniker string) []corev1.Conta
required := []corev1.Container{
{
Name: "clean-init",
Image: infraToolImage,
Image: resolveInfraToolImage(),
Command: []string{"sh"},
Args: []string{"-c", `rm -rf "$HOME/.tmp/*"`},
Env: env,
Expand Down Expand Up @@ -385,7 +390,7 @@ echo "Initializing into tmp dir for downstream processing..."

{
Name: "genesis-init",
Image: infraToolImage,
Image: resolveInfraToolImage(),
Command: []string{genesisCmd},
Args: genesisArgs,
Env: env,
Expand All @@ -394,7 +399,7 @@ echo "Initializing into tmp dir for downstream processing..."
},
{
Name: "addrbook-init",
Image: infraToolImage,
Image: resolveInfraToolImage(),
Command: []string{addrbookCmd},
Args: addrbookArgs,
Env: env,
Expand All @@ -403,7 +408,7 @@ echo "Initializing into tmp dir for downstream processing..."
},
{
Name: "config-merge",
Image: infraToolImage,
Image: resolveInfraToolImage(),
Command: []string{"sh"},
Args: []string{"-c",
`
Expand Down Expand Up @@ -434,7 +439,7 @@ config-merge -f toml "$TMP_DIR/app.toml" "$OVERLAY_DIR/app-overlay.toml" > "$CON
cmd, args := DownloadSnapshotCommand(crd.Spec.ChainSpec)
required = append(required, corev1.Container{
Name: "snapshot-restore",
Image: infraToolImage,
Image: resolveInfraToolImage(),
Command: []string{cmd},
Args: args,
Env: env,
Expand Down
10 changes: 5 additions & 5 deletions internal/fullnode/pod_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,12 @@ func TestPodBuilder(t *testing.T) {
require.Len(t, lo.Map(pod.Spec.InitContainers, func(c corev1.Container, _ int) string { return c.Name }), 7)

wantInitImages := []string{
"ghcr.io/strangelove-ventures/infra-toolkit:v0.0.1",
"ghcr.io/strangelove-ventures/infra-toolkit:v0.1.6",
"main-image:v1.2.3",
"ghcr.io/strangelove-ventures/infra-toolkit:v0.0.1",
"ghcr.io/strangelove-ventures/infra-toolkit:v0.0.1",
"ghcr.io/strangelove-ventures/infra-toolkit:v0.0.1",
"ghcr.io/strangelove-ventures/infra-toolkit:v0.0.1",
"ghcr.io/strangelove-ventures/infra-toolkit:v0.1.6",
"ghcr.io/strangelove-ventures/infra-toolkit:v0.1.6",
"ghcr.io/strangelove-ventures/infra-toolkit:v0.1.6",
"ghcr.io/strangelove-ventures/infra-toolkit:v0.1.6",
"ghcr.io/strangelove-ventures/cosmos-operator:latest",
}
require.Equal(t, wantInitImages, lo.Map(pod.Spec.InitContainers, func(c corev1.Container, _ int) string {
Expand Down
6 changes: 6 additions & 0 deletions internal/fullnode/script/download-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ download_lz4() {
wget -c -O - "$SNAPSHOT_URL" | lz4 -c -d | tar -x -C "$CHAIN_HOME"
}

download_zst() {
echo "Downloading and extracting zst..."
wget -c -O - "$SNAPSHOT_URL" | zstd -d --stdout | tar -x -C "$CHAIN_HOME"
}

case "$SNAPSHOT_URL" in
*.tar.lz4) download_lz4 ;;
*.tar.zst) download_zst ;;
*.tar.gzip) download_targz ;;
*.tar.gz) download_targz ;;
*.tar) download_tar ;;
Expand Down
Loading