Skip to content

Conversation

@sklarsa
Copy link
Contributor

@sklarsa sklarsa commented Mar 25, 2025

Instead of checking for tables.d.0, we should check for the existence of tables.d.* as evidence that we are inside the db directory as part of the migration to v1.x.x.

@sklarsa
Copy link
Contributor Author

sklarsa commented Mar 25, 2025

@nwoolmer here's a test script to validate:

#!/bin/bash

set -e

# Set up test cluster
kind create cluster -n qdbtest

# Install last previous version
helm upgrade --install questdb questdb/questdb --version 0.42.1

echo "TEST SCRIPT: Waiting for deployment to finish (could take a minute or two depending on download speeds, be patient)"
sleep 10
kubectl wait --for=condition=Ready pod/questdb-0 --timeout=120s

# Sanity check to check the pod contents
kubectl exec -it questdb-0 -- ls -lah /var/lib/questdb


# Confirm contents of persistent volume claim
# Root of the volume should map to /var/lib/questdb/db
PV_PATH=$(kubectl get pv -o json | jq -r '.items[0].spec.hostPath.path')
echo "TEST SCRIPT: PV path on node: $PV_PATH"
echo "TEST SCRIPT: (Pre Migration) Contents of $PV_PATH"
docker exec qdbtest-control-plane ls -lah $PV_PATH

# Check out the new branch to install the patched version
git checkout steve/fix-data-migration-script
helm upgrade --install questdb ./charts/questdb

echo "TEST SCRIPT: Waiting for deployment to finish"
sleep 10
kubectl wait --for=condition=Ready pod/questdb-0 --timeout=60s

# Sanity check to check the pod contents
echo "TEST SCRIPT: (Post Migration) contents of /var/lib/questdb inside container"
kubectl exec -it questdb-0 -- ls -lah /var/lib/questdb

# Now confirm that the contents of the pvc map to the database root dir
echo "TEST SCRIPT: (Post Migration) contents of $PV_PATH"
docker exec qdbtest-control-plane ls -lah $PV_PATH

# Check init script logs
echo "TEST SCRIPT: init container logs"
kubectl logs questdb-0 -c init-db-migration

echo "TEST SCRIPT: scaling down and up to ensure that migration does not run again"

# Scale down the statefulset
kubectl scale statefulset questdb --replicas=0
sleep 1

# Scale up the statefulset
kubectl scale statefulset questdb --replicas=1
sleep 5

# Wait for the pod to be ready again
kubectl wait --for=condition=Ready pod/questdb-0 --timeout=30s

# Check init script logs
echo "TEST SCRIPT: init container logs"
kubectl logs questdb-0 -c init-db-migration

# Clean up
kind delete cluster -n qdbtest

@sklarsa sklarsa merged commit 7f32649 into master Mar 25, 2025
1 check passed
@sklarsa sklarsa deleted the steve/fix-data-migration-script branch March 25, 2025 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants