Skip to content

Upgrading Shoehorn

Before upgrading, check the release notes for:

  • Breaking changes
  • New required environment variables
  • Database migration requirements
  • Deprecated features
Terminal window
# Using pg_dump
pg_dump -h <host> -U shoehorn_user -d shoehorn > backup_$(date +%Y%m%d).sql
# Or using kubectl, with the bundled PostgreSQL
kubectl exec -n shoehorn statefulset/shoehorn-postgresql -- \
pg_dump -U shoehorn_user shoehorn > backup.sql

Note the migration version you’re on as well. You need it if you roll back:

Terminal window
# With the bundled PostgreSQL
kubectl exec -n shoehorn statefulset/shoehorn-postgresql -- \
psql -U shoehorn_user -d shoehorn -c "SELECT version, dirty FROM schema_migrations"
# Or against your own server
psql -h <host> -U shoehorn_user -d shoehorn \
-c "SELECT version, dirty FROM schema_migrations"

Update the image tag in your values file:

image:
tag: "0.7.0" # New version
Terminal window
helm upgrade shoehorn oci://ghcr.io/shoehorn-dev/helm-charts/shoehorn \
--namespace shoehorn \
-f values.yaml

Helm will:

  1. Apply new container images
  2. Run database migrations automatically (init container)
  3. Rolling-restart services with zero downtime

PostgreSQL is not restarted by helm upgrade. See PostgreSQL upgrades below.

Terminal window
# Check rollout status
kubectl rollout status -n shoehorn deploy/shoehorn-api
# Check API health
kubectl port-forward -n shoehorn svc/shoehorn-api 8080:8080
curl http://localhost:8080/healthz
# Check the migration logs (the API pod's migrate init container)
kubectl logs -n shoehorn deploy/shoehorn-api -c migrate --tail=100

The chart upgrades the search engine, cache and event stream with each release. 0.7.0 ships:

Component Version Why it matters
Meilisearch v1.56.2 v1.56.1 had a leftover debug statement that slows search down.
Valkey 9.1.4 9.1.3 and 9.1.4 fix two security issues.
Redpanda v26.2.7 Latest patch release of 26.2.
PostgreSQL shoehorned/shoehorn-postgres:v18.3-pgaudit-1.0 Unchanged in this release.

If your values file pins any of these images (meilisearch.image.tag, valkey.image.tag, redpanda.image.tag), move the pin to the version in this table, or remove it to follow the chart. Valkey and Redpanda restart one pod at a time. Meilisearch migrates its data on the first start of a new version, so read Meilisearch upgrades and back up first.

Tracing needs a CA file outside development

Section titled “Tracing needs a CA file outside development”

If you send traces to an OpenTelemetry collector, check this before upgrading to 0.7.0. Outside development, Shoehorn now connects to the collector over TLS and checks its certificate against a CA. Give it your collector’s CA with global.tracing.caSecretRef (a secret name and the key holding the PEM file). With global.mtls.enabled, Shoehorn uses the mesh CA when you don’t set one. Without a CA, tracing stays off after the upgrade and each service logs a warning. The rest of Shoehorn keeps working. See Distributed Tracing.

The postgres StatefulSet uses updateStrategy: OnDelete and pins its image in values.yaml (e.g. shoehorned/shoehorn-postgres:v18.3-pgaudit-1.0). helm upgrade won’t restart the pod even if the chart bumps the tag. Roll it deliberately:

Terminal window
kubectl get sts -n shoehorn shoehorn-postgresql -o jsonpath='{.spec.template.spec.containers[0].image}'
kubectl delete pod -n shoehorn shoehorn-postgresql-0

The PVC stays attached. Data is preserved.

The StatefulSet, PVC, and Service carry helm.sh/resource-policy: keep. helm uninstall leaves them in place. Delete them by hand for a clean slate.

For an external database, set postgresql.external.enabled: true with its host, port, database and user, and give the passwords through postgresql.superuserPasswordSecretRef (the user that runs migrations) and postgresql.passwordSecretRef (app_user).

If you previously ran Redpanda without persistence (redpanda.persistence.enabled: false, data on an emptyDir) and switch it on, a plain helm upgrade fails. A StatefulSet’s volume claim template can’t be added after creation, so the API server rejects the change.

Delete the StatefulSet first, then upgrade. The emptyDir only held in-flight events, so this loses nothing a normal restart wouldn’t:

Terminal window
kubectl delete statefulset shoehorn-redpanda -n shoehorn
helm upgrade shoehorn ... --values custom-values.yaml --wait

Redpanda comes back on a PVC and keeps its data across restarts from then on. The api, worker, crawler, and forge pods get connection errors during the recreate and reconnect once it’s ready.

Meilisearch won’t start when its data directory was written by an older version. When a platform release bumps the bundled search engine, the Meilisearch pod boots the new binary on the old volume and crashloops with a “database version is incompatible” error until the data is migrated.

The chart handles this for you. meilisearch.upgradeOnStart is on by default and migrates the data directory in place the first time the new version boots; later restarts are a no-op. The migration rewrites the data directory and a plain image downgrade won’t undo it, so back up first.

1. Back up. Trigger a Meilisearch snapshot, and snapshot the PVC (data-shoehorn-meilisearch-0) if your storage class supports VolumeSnapshots.

Terminal window
kubectl -n shoehorn port-forward svc/shoehorn-meilisearch 7700:7700 &
curl -X POST http://127.0.0.1:7700/snapshots -H "Authorization: Bearer $MEILI_MASTER_KEY"

2. Raise the startup budget. A large index can take minutes to migrate, and the default startup probe kills the pod after about 150s.

meilisearch:
startupProbe:
httpGet: { path: /health, port: 7700 }
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 180 # about 15 min, put it back afterwards
timeoutSeconds: 3

3. Upgrade and watch the pod come back on the new version.

Terminal window
helm upgrade shoehorn oci://ghcr.io/shoehorn-dev/helm-charts/shoehorn --namespace shoehorn -f values.yaml --wait
kubectl -n shoehorn logs -f shoehorn-meilisearch-0
kubectl -n shoehorn get pod shoehorn-meilisearch-0 -w

Run a search in the app to confirm results come back.

4. Put the startup budget back. Drop the startupProbe override and upgrade again. Leave upgradeOnStart on. It has nothing to do until the next version bump.

If the pod won’t come up, roll back with helm rollback and restore Meilisearch from the snapshot. Without a snapshot, start the pod on an empty volume and rebuild the indexes from your database with POST /api/v1/admin/backfill, then POST /api/v1/admin/recrawl for document content. For the full step-by-step, including migrating by hand with upgradeOnStart turned off, see Upgrading Meilisearch in the chart README.

If the new release added no database migrations, helm rollback is all you need:

Terminal window
# Roll back to the previous release
helm rollback shoehorn -n shoehorn
# Or to a specific revision
helm history shoehorn -n shoehorn
helm rollback shoehorn <revision-number> -n shoehorn

If you installed with the Terraform module, set image_tag (and chart_version, if you pin it) back to the previous release and run terraform apply instead. A later apply would undo a helm rollback.

If the new release added migrations, the older release won’t start: its migrate init container doesn’t know them and stops with no migration found for version <N>. Migrate the database back first, with the new release’s own image. You need jq.

1. Stop the new release’s API pods. Every API pod migrates when it starts, so one that restarts during the rollback would apply the migrations again:

Terminal window
kubectl scale -n shoehorn deploy/shoehorn-api --replicas=0
until [ -z "$(kubectl get pod -n shoehorn -o name \
-l app.kubernetes.io/instance=shoehorn,app.kubernetes.io/component=api)" ]; do
sleep 5
done

2. Check where the database is. With the bundled PostgreSQL:

Terminal window
kubectl exec -n shoehorn statefulset/shoehorn-postgresql -- \
psql -U shoehorn_user -d shoehorn -c "SELECT version, dirty FROM schema_migrations"

3. Run the migration commands. This helper runs the new release’s migrate container once with a migration flag and a version, waits for it to end, then prints its logs:

Terminal window
migrate_once() {
kubectl delete pod -n shoehorn shoehorn-migrate-once --ignore-not-found
kubectl get deploy -n shoehorn shoehorn-api -o json \
| jq --arg flag "$1" --arg version "$2" '
{apiVersion: "v1", kind: "Pod",
metadata: {name: "shoehorn-migrate-once"},
spec: (.spec.template.spec
| .restartPolicy = "Never"
| .containers = [.initContainers[] | select(.name == "migrate")
| .command = ["/api", $flag, $version]]
| del(.initContainers))}' \
| kubectl apply -n shoehorn -f -
until kubectl get pod -n shoehorn shoehorn-migrate-once \
-o jsonpath='{.status.phase}' | grep -qE 'Succeeded|Failed'; do
sleep 5
done
kubectl logs -n shoehorn shoehorn-migrate-once
kubectl get pod -n shoehorn shoehorn-migrate-once -o jsonpath='{.status.phase}{"\n"}'
}

Say you noted version 206 before upgrading, and the new release added 207 to 209. If step 2 showed dirty = true, the newer migration failed partway. Its changes almost always roll back with it, since a migration runs as one transaction. Mark the version before it as current first (here 209 was dirty):

Terminal window
migrate_once --migrate-force 208

Then migrate to the version you noted:

Terminal window
migrate_once --migrate-version 206
kubectl delete pod -n shoehorn shoehorn-migrate-once

Both commands should end with Succeeded. If one ends with Failed, its logs say why. Down migrations can drop data that newer features wrote. If that matters, if a step fails, or if you didn’t note the version, restore the backup from step 2 of the upgrade instead.

4. Roll back. Run helm rollback as above. It brings back the old replica count. With api.autoscaling.enabled, scale the API back up yourself and the autoscaler takes over from there:

Terminal window
kubectl scale -n shoehorn deploy/shoehorn-api --replicas=1

The K8s agent can be upgraded independently of the main platform:

Terminal window
helm upgrade shoehorn-k8s-agent oci://ghcr.io/shoehorn-dev/helm-charts/shoehorn-k8s-agent \
--namespace shoehorn-agent \
-f agent-values.yaml

The agent is backward-compatible with older API versions. Upgrade the platform first, then agents.

Things to watch during an agent upgrade:

  • Leader re-election: The rolling restart triggers a new leader election. There is a brief gap (a few seconds) between the old leader stopping and the new leader starting. No data is lost – events are buffered in the Kubernetes informer cache.
  • HA deployments: With a PodDisruptionBudget in place, at least one replica stays available throughout the upgrade. A follower takes over leader election within seconds.
  • Configuration validation: If the new agent version introduces stricter configuration parsing, invalid environment variables that were previously silently accepted may cause startup failures. Check pod logs if a new version does not become ready.

See the shoehorn-dev/helm-charts repository for the chart changelog and values reference.