Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat(minikube): rebuild control-postgres by default in full-setup

Jose Ramirezfcc05f20dada
diff --git a/scripts/minikube/full-setup.sh b/scripts/minikube/full-setup.sh
index 3ea86d929..538d9bf72 100755
--- a/scripts/minikube/full-setup.sh
+++ b/scripts/minikube/full-setup.sh
@@ -111,7 +111,7 @@ validate_mcpserver_secrets() {
# ── Parse flags ────────────────────────────────────────────────────────
SKIP_BUILD=false
SKIP_UIS="${MINIKUBE_SKIP_UIS:-false}"
-RESET_DB=false
+RESET_DB=true
FORCE_KEYS=false
case "${SKIP_UIS}" in
@@ -119,6 +119,16 @@ case "${SKIP_UIS}" in
*) SKIP_UIS=false ;;
esac
+# Rebuild the DB from scratch by default (RESET_DB=true above) so a stale
+# control-postgres volume from an older build cannot drift from the current
+# schema/grant contract: the migration gate enforces an exact runtime-access
+# contract, and already-recorded migrations never re-run to reconcile it. Opt
+# out with REUSE_DB=true (or --keep-db) to preserve an existing volume.
+case "${REUSE_DB:-false}" in
+ true|1|yes) RESET_DB=false ;;
+ *) : ;;
+esac
+
SEED_PROFILE="${MINIKUBE_SEED_PROFILE:-minimal}"
# Unlike the SKIP_UIS boolean normalizer, an unrecognized profile is a hard
@@ -145,7 +155,8 @@ Options:
test fixtures. e2e: adds the E2E fixtures (test user,
e2e-* recipes, demo MCP servers). Requires ADMIN_PASSWORD
unless --seed-profile=e2e.
- --reset-db Reset postgres database for MINIKUBE_PROFILE (deletes PVC, re-deploys)
+ --reset-db Force a postgres DB rebuild (already the default; deletes PVC, re-deploys)
+ --keep-db Preserve the existing postgres DB volume (skip the default rebuild)
--force-keys Force JWT key regeneration (invalidates existing tokens)
-h, --help Show this help message
@@ -154,6 +165,8 @@ Environment:
MINIKUBE_MULTI_NODE Set true to opt into a two-node local cluster
MINIKUBE_NODES Explicit node count; values >1 imply multi-node
MINIKUBE_SKIP_UIS Set true to skip Control UI, Profile UI, and Desktop App
+ REUSE_DB Set true to preserve the existing postgres DB volume;
+ default rebuilds control-postgres from scratch every run
MINIKUBE_SEED_PROFILE, ADMIN_PASSWORD
See --seed-profile above
MINIKUBE_RECREATE_PROFILE
@@ -174,7 +187,7 @@ Examples:
$(basename "$0") --skip-build # Re-deploy without rebuilding images
$(basename "$0") --skip-uis # Deploy backend services without UIs
$(basename "$0") --seed-profile=e2e # Full E2E fixture set
- $(basename "$0") --reset-db # Fix postgres WAL corruption
+ $(basename "$0") --keep-db # Preserve the existing DB (skip the default rebuild)
$(basename "$0") --force-keys # Regenerate all JWT keys
EOF
exit 0
@@ -186,6 +199,7 @@ for arg in "$@"; do
--skip-uis) SKIP_UIS=true ;;
--seed-profile=*) SEED_PROFILE="${arg#*=}" ;;
--reset-db) RESET_DB=true ;;
+ --keep-db) RESET_DB=false ;;
--force-keys) FORCE_KEYS=true ;;
-h|--help) usage ;;
*) err "Unknown flag: $arg"; usage ;;
@@ -582,7 +596,7 @@ step_header 6 $TOTAL_STEPS "Deploy"
# 6a. Optional DB reset
if [ "$RESET_DB" = true ]; then
- log "Resetting postgres database (--reset-db)..."
+ log "Rebuilding postgres database from scratch (set REUSE_DB=true to keep it)..."
# Scale down to release PVC
$KC scale deployment/control-api -n control-plane --replicas=0 2>/dev/null || true
$KC scale deployment/control-postgres -n control-plane --replicas=0 2>/dev/null || true
diff --git a/scripts/tests/test-minikube-full-setup.sh b/scripts/tests/test-minikube-full-setup.sh
index e9f486f71..439063c1d 100755
--- a/scripts/tests/test-minikube-full-setup.sh
+++ b/scripts/tests/test-minikube-full-setup.sh
@@ -256,11 +256,23 @@ assert_gfs_provisioning_follows_migrations_and_core_readiness() {
fi
}
+assert_full_setup_defaults_to_db_rebuild() {
+ if grep -Eq '^RESET_DB=true$' scripts/minikube/full-setup.sh && \
+ grep -Fq 'case "${REUSE_DB:-false}" in' scripts/minikube/full-setup.sh && \
+ grep -Eq -- '--keep-db\)[[:space:]]+RESET_DB=false' scripts/minikube/full-setup.sh && \
+ grep -Fq 'delete pvc control-postgres-data' scripts/minikube/full-setup.sh; then
+ pass "full-setup rebuilds the DB by default with a REUSE_DB/--keep-db opt-out"
+ else
+ fail "full-setup does not default to a clean DB rebuild with a REUSE_DB/--keep-db opt-out"
+ fi
+}
+
assert_broken_profile_is_recreated
assert_healthy_profile_skips_recreate
assert_branch_profile_deploy_dir_is_used
assert_member_registration_hmac_is_patched
assert_branch_scoped_minikube_context_is_supported
assert_gfs_provisioning_follows_migrations_and_core_readiness
+assert_full_setup_defaults_to_db_rebuild
exit $FAIL