Upgrades
Upgrades
Section titled “Upgrades”Upgrade Mantis components safely with zero-downtime strategies.
Upgrade Planning
Section titled “Upgrade Planning”Version Compatibility
Section titled “Version Compatibility”Before upgrading, verify compatibility:
| Component | Compatibility |
|---|---|
| Mandible ↔ Thorax | Must match major.minor version |
| Thorax ↔ Tarsus | Backward compatible within major version |
| Database schema | Managed by migrations |
Pre-Upgrade Checklist
Section titled “Pre-Upgrade Checklist”- Review release notes for breaking changes
- Backup database
- Backup configuration files
- Test upgrade in staging environment
- Schedule maintenance window (if needed)
- Notify stakeholders
- Verify rollback plan
Upgrade Order
Section titled “Upgrade Order”Always upgrade in this order:
Docker Compose Upgrades
Section titled “Docker Compose Upgrades”Standard Upgrade
Section titled “Standard Upgrade”# Pull latest imagesdocker compose pull
# Stop servicesdocker compose down
# Run migrations using diesel CLIcd instinctdiesel migration run
# Start with new imagesdocker compose up -d
# Verify healthdocker compose pscurl https://localhost:3000/api/v1/healthRolling Upgrade (Zero Downtime)
Section titled “Rolling Upgrade (Zero Downtime)”For high availability setups with multiple replicas:
# Pull new imagesdocker compose pull
# Scale up with new versiondocker compose up -d --scale mandible=4 --scale thorax=4
# Wait for new containers to be healthysleep 30
# Scale down to remove old containersdocker compose up -d --scale mandible=2 --scale thorax=2Rollback
Section titled “Rollback”# Stop current versiondocker compose down
# Specify previous versionexport MANTIS_VERSION=1.2.3docker compose up -dKubernetes Upgrades
Section titled “Kubernetes Upgrades”Standard Rolling Update
Section titled “Standard Rolling Update”# Update image tag in deploymentkubectl set image deployment/mandible mandible=ghcr.io/mantisplatform/mantis-mandible:v1.3.0 -n mantiskubectl set image deployment/thorax thorax=ghcr.io/mantisplatform/mantis-thorax:v1.3.0 -n mantiskubectl set image deployment/lens lens=ghcr.io/mantisplatform/mantis-lens:v1.3.0 -n mantis
# Monitor rolloutkubectl rollout status deployment/mandible -n mantiskubectl rollout status deployment/thorax -n mantisBlue-Green Deployment
Section titled “Blue-Green Deployment”apiVersion: apps/v1kind: Deploymentmetadata: name: mandible-v2 namespace: mantisspec: replicas: 2 selector: matchLabels: app: mantis component: mandible version: v2 template: metadata: labels: app: mantis component: mandible version: v2 spec: containers: - name: mandible image: ghcr.io/mantisplatform/mantis-mandible:v1.3.0 # ... rest of specSwitch traffic:
# Deploy new versionkubectl apply -f deployments/mandible-v2.yaml
# Wait for readykubectl rollout status deployment/mandible-v2 -n mantis
# Update service selector to new versionkubectl patch service mandible -n mantis -p '{"spec":{"selector":{"version":"v2"}}}'
# Verify traffic flows to new versionkubectl get endpoints mandible -n mantis
# Remove old deployment after validationkubectl delete deployment mandible-v1 -n mantisCanary Deployment
Section titled “Canary Deployment”# Deploy canary with subset of trafficapiVersion: apps/v1kind: Deploymentmetadata: name: mandible-canary namespace: mantisspec: replicas: 1 selector: matchLabels: app: mantis component: mandible track: canary template: metadata: labels: app: mantis component: mandible track: canary spec: containers: - name: mandible image: ghcr.io/mantisplatform/mantis-mandible:v1.3.0Rollback
Section titled “Rollback”# Rollback to previous revisionkubectl rollout undo deployment/mandible -n mantis
# Or to specific revisionkubectl rollout undo deployment/mandible --to-revision=2 -n mantis
# Check rollback statuskubectl rollout status deployment/mandible -n mantisDatabase Migrations
Section titled “Database Migrations”Running Migrations
Section titled “Running Migrations”Migrations must run before deploying new application code:
# Using diesel CLI (recommended)cd instinctdiesel migration run
# Kubernetes - use a job with diesel CLIkubectl create job --from=cronjob/mantis-migration mantis-migration-v1.3.0 -n mantiskubectl wait --for=condition=complete job/mantis-migration-v1.3.0 -n mantisMigration Best Practices
Section titled “Migration Best Practices”- Always backup before migrations
pg_dump -h localhost -U mantis mantis > backup-$(date +%Y%m%d).sql- Run migrations in a transaction
Mantis migrations run in transactions by default. If a migration fails, changes are rolled back.
- Test migrations on a copy first
# Create test databasecreatedb mantis_upgrade_testpg_restore -d mantis_upgrade_test backup.sql
# Run migration against test databasecd instinctDATABASE_URL="postgres://localhost/mantis_upgrade_test" diesel migration runHandling Migration Failures
Section titled “Handling Migration Failures”If a migration fails:
- Check the error message in logs
- Do not retry without investigating
- Fix the underlying issue
- Migration state is tracked in
__diesel_schema_migrationstable
-- Check migration statusSELECT * FROM __diesel_schema_migrations ORDER BY run_on DESC;
-- If needed, manually mark migration as rolled back-- WARNING: Only do this if you understand the consequencesDELETE FROM __diesel_schema_migrations WHERE version = 'YYYYMMDDHHMMSS';Tarsus Agent Upgrades
Section titled “Tarsus Agent Upgrades”Upgrade Strategies
Section titled “Upgrade Strategies”| Strategy | Description | Downtime |
|---|---|---|
| Rolling | Upgrade agents one at a time | None |
| Batch | Upgrade groups by environment | Minimal |
| Full | Upgrade all agents simultaneously | Brief |
Rolling Upgrade Script
Section titled “Rolling Upgrade Script”#!/bin/bash# List target IDs via the REST API (there is no `mantisctl targets` subcommand)AGENTS=$(curl -s -H "Authorization: Bearer $TOKEN" \ "https://api.mantis.example.com/api/v1/targets" | jq -r '.data[].id')NEW_VERSION="1.3.0"
for agent in $AGENTS; do echo "Upgrading $agent..."
# Deploy upgrade package with mantisctl mantisctl deployment create \ --solution-id "$TARSUS_UPGRADE_SOLUTION_ID" \ --target "$agent" \ --var "version=$NEW_VERSION" \ --follow
echo "Completed $agent"doneManual Agent Upgrade
Section titled “Manual Agent Upgrade”On each target server:
# Stop agentsudo systemctl stop tarsus
# Backup current binarysudo cp /usr/local/bin/tarsus /usr/local/bin/tarsus.backup
# Download new versioncurl -L https://releases.mantis.example.com/tarsus/v1.3.0/tarsus-linux-amd64 \ -o /usr/local/bin/tarsus
# Set permissionssudo chmod 755 /usr/local/bin/tarsus
# Start agentsudo systemctl start tarsus
# Verifytarsus --versionConfiguration Changes
Section titled “Configuration Changes”Adding New Settings
Section titled “Adding New Settings”New configuration options typically have sensible defaults. For example, Thorax exposes a
[session] section and Mandible exposes a [client_session] section:
# Thorax session tuning[session]heartbeat_timeout_secs = 90
# Mandible client-session tuning[client_session]max_concurrent_commands = 10Deprecated Settings
Section titled “Deprecated Settings”Check the release notes for any renamed or removed settings before upgrading. The current
database pool keys are max_connections, min_idle, and connection_timeout_secs:
[database]max_connections = 10min_idle = 2connection_timeout_secs = 10Environment Variable Changes
Section titled “Environment Variable Changes”Update environment files:
# Check for new/changed variablesdiff .env.example .env
# Update environmentnano .envVersion-Specific Guides
Section titled “Version-Specific Guides”Breaking Changes Log
Section titled “Breaking Changes Log”| Version | Breaking Change | Migration Path |
|---|---|---|
| v1.0.0 | Initial release | N/A |
Monitoring Upgrades
Section titled “Monitoring Upgrades”Health Checks During Upgrade
Section titled “Health Checks During Upgrade”# Continuous health monitoringwatch -n 2 'curl -s https://localhost:3000/api/v1/health | jq'
# Check specific componentcurl https://localhost:3000/api/v1/health/readyKey Metrics to Watch
Section titled “Key Metrics to Watch”| Metric | Normal | Alert |
|---|---|---|
| Request latency | < 100ms | > 500ms |
| Error rate | < 0.1% | > 1% |
| Active connections | Stable | Spike/drop |
| Memory usage | Stable | Growing |
Log Analysis
Section titled “Log Analysis”# Watch for errors during upgradedocker compose logs -f --since 5m | grep -i error
# Kuberneteskubectl logs -l app=mantis -n mantis -f --since=5m | grep -i errorRollback Procedures
Section titled “Rollback Procedures”Docker Compose Rollback
Section titled “Docker Compose Rollback”# Immediate rollbackdocker compose downexport MANTIS_VERSION=previous-versiondocker compose up -d
# Database rollback (if needed)psql -U mantis mantis < backup.sqlKubernetes Rollback
Section titled “Kubernetes Rollback”# Rollback deploymentskubectl rollout undo deployment/mandible -n mantiskubectl rollout undo deployment/thorax -n mantiskubectl rollout undo deployment/lens -n mantis
# Database rollback (if needed)kubectl exec -it postgres-0 -n mantis -- psql -U mantis -f /backup/backup.sqlDatabase Rollback
Section titled “Database Rollback”# Restore from backuppg_restore -h localhost -U mantis -d mantis --clean backup.dump
# Or from SQL dumppsql -h localhost -U mantis -d mantis < backup.sqlMaintenance Windows
Section titled “Maintenance Windows”Scheduling
Section titled “Scheduling”For upgrades requiring downtime:
- Announce maintenance - Notify users 24-48 hours in advance
- Freeze deployments - Prevent new deployments during upgrade
- Backup everything - Database, configs, certificates
- Perform upgrade - Follow upgrade procedures
- Validate - Run smoke tests
- Resume operations - Unfreeze and notify users
Creating Deployment Freeze
Section titled “Creating Deployment Freeze”# In Lens UI: Freezes → New Freeze (top-level nav, path /freezes/new)# Or via API:curl -X POST https://api.mantis.example.com/api/v1/deployment-freezes \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Upgrade Maintenance", "start_time": "2024-01-15T02:00:00Z", "end_time": "2024-01-15T04:00:00Z" }'# Omitting tenant_id/solution_id/environment_id applies the freeze globally.Troubleshooting
Section titled “Troubleshooting”Upgrade Failed
Section titled “Upgrade Failed”- Check logs for specific errors
- Verify all prerequisites met
- Ensure database migrations completed
- Check connectivity between components
Version Mismatch
Section titled “Version Mismatch”# Check tarsus version (supports --version via clap)tarsus --version
# Check mandible and thorax versions via the server info endpointcurl -s https://localhost:3000/api/v1/server/info | jq '.server_version'
# Verify the API is healthy after the upgradecurl https://localhost:3000/api/v1/health | jq '.status'Database Migration Stuck
Section titled “Database Migration Stuck”# Check migration statuspsql -U mantis -c "SELECT * FROM __diesel_schema_migrations"
# Check for lockspsql -U mantis -c "SELECT * FROM pg_locks WHERE NOT granted"Next Steps
Section titled “Next Steps”- Production Checklist - Verify production readiness
- Backup & Recovery - Backup procedures
- Troubleshooting - Common issues
