|
1 | 1 | # Vulcan Upgrade Guide |
2 | 2 |
|
3 | | -## Quick Start (for any version upgrade) |
| 3 | +## Quick Start |
4 | 4 |
|
5 | | -### Step 1: Install the upgrade toolkit |
| 5 | +The upgrade toolkit is built into every Vulcan image from v2.3.6+. No file injection, no extra installs — just pull and run. |
6 | 6 |
|
7 | | -Choose the method that matches your deployment: |
8 | | - |
9 | | -#### Bare metal / systemd |
| 7 | +### Docker Compose (most common) |
10 | 8 |
|
11 | 9 | ```bash |
12 | | -# Download directly into your Vulcan source tree |
13 | | -cd /path/to/vulcan |
14 | | -curl -fsSL https://raw.githubusercontent.com/mitre/vulcan/master/lib/tasks/upgrade_preflight.rake \ |
15 | | - -o lib/tasks/upgrade_preflight.rake |
16 | | -``` |
| 10 | +# 1. Back up your database |
| 11 | +docker compose exec db pg_dump -Fc -U postgres vulcan_postgres_production \ |
| 12 | + > vulcan_backup_$(date +%Y%m%d).dump |
17 | 13 |
|
18 | | -#### Docker Compose |
| 14 | +# 2. Pull the new image (or update your image tag in docker-compose.yml) |
| 15 | +docker compose pull |
19 | 16 |
|
20 | | -```bash |
21 | | -# Copy the rake file into your RUNNING container (no image rebuild needed) |
22 | | -curl -fsSL https://raw.githubusercontent.com/mitre/vulcan/master/lib/tasks/upgrade_preflight.rake \ |
23 | | - -o /tmp/upgrade_preflight.rake |
24 | | -docker cp /tmp/upgrade_preflight.rake $(docker compose ps -q web):/rails/lib/tasks/upgrade_preflight.rake |
25 | | -``` |
| 17 | +# 3. Preflight check (runs the NEW image against your EXISTING database) |
| 18 | +docker compose run --rm web rails upgrade:preflight |
26 | 19 |
|
27 | | -#### ECS / Kubernetes / any container orchestrator |
| 20 | +# 4. Fix any issues it finds |
| 21 | +docker compose run --rm web rails upgrade:fix |
28 | 22 |
|
29 | | -```bash |
30 | | -# Option A: Exec into the running task/pod and download |
31 | | -kubectl exec -it deploy/vulcan-web -- bash -c \ |
32 | | - "curl -fsSL https://raw.githubusercontent.com/mitre/vulcan/master/lib/tasks/upgrade_preflight.rake \ |
33 | | - -o lib/tasks/upgrade_preflight.rake" |
34 | | - |
35 | | -# Option B: If curl isn't available in the container, copy from local |
36 | | -kubectl cp /tmp/upgrade_preflight.rake vulcan-web-pod:/rails/lib/tasks/upgrade_preflight.rake |
37 | | - |
38 | | -# ECS equivalent (using aws cli + ssm exec) |
39 | | -aws ecs execute-command --cluster vulcan --task $TASK_ID --container web \ |
40 | | - --command "curl -fsSL https://raw.githubusercontent.com/mitre/vulcan/master/lib/tasks/upgrade_preflight.rake \ |
41 | | - -o lib/tasks/upgrade_preflight.rake" --interactive |
42 | | -``` |
| 23 | +# 5. Start (db:prepare runs automatically via the entrypoint) |
| 24 | +docker compose up -d |
43 | 25 |
|
44 | | -#### Can't modify the container at all? |
| 26 | +# 6. Verify |
| 27 | +docker compose exec web rails upgrade:verify |
| 28 | +``` |
45 | 29 |
|
46 | | -Use the standalone diagnostic script — no Rails required, just `psql`: |
| 30 | +### Kubernetes / ECS |
47 | 31 |
|
48 | 32 | ```bash |
49 | | -# Download and run from any machine that can reach your database |
50 | | -curl -fsSL https://raw.githubusercontent.com/mitre/vulcan/master/bin/upgrade-check.sh \ |
51 | | - -o upgrade-check.sh && chmod +x upgrade-check.sh |
52 | | - |
53 | | -# Point it at your database |
54 | | -./upgrade-check.sh postgres://user:pass@your-db-host:5432/vulcan_production |
| 33 | +# 1. Back up your database (use your standard backup procedure) |
| 34 | + |
| 35 | +# 2. Run preflight as a one-shot pod/task with the NEW image |
| 36 | +kubectl run vulcan-preflight --rm -it \ |
| 37 | + --image=mitre/vulcan:v2.3.6 \ |
| 38 | + --env-from=secret/vulcan-env \ |
| 39 | + -- rails upgrade:preflight |
| 40 | + |
| 41 | +# 3. Fix if needed |
| 42 | +kubectl run vulcan-fix --rm -it \ |
| 43 | + --image=mitre/vulcan:v2.3.6 \ |
| 44 | + --env-from=secret/vulcan-env \ |
| 45 | + -- rails upgrade:fix |
| 46 | + |
| 47 | +# 4. Deploy the new image (your standard deploy process) |
| 48 | +# 5. Verify |
| 49 | +kubectl exec -it deploy/vulcan-web -- rails upgrade:verify |
55 | 50 | ``` |
56 | 51 |
|
57 | | -No gem installs, no Gemfile changes, no image rebuilds. The rake task is one file that uses Rails APIs already in the app. The shell script uses only `psql`. |
58 | | - |
59 | | -### Step 2: Back up your database |
60 | | - |
61 | | -**Do this before anything else.** Every upgrade path is tested, but your data is unique. |
| 52 | +### Bare metal / systemd |
62 | 53 |
|
63 | 54 | ```bash |
64 | | -# Vanilla PostgreSQL |
| 55 | +# 1. Back up |
65 | 56 | pg_dump -Fc your_database > vulcan_backup_$(date +%Y%m%d).dump |
66 | 57 |
|
67 | | -# Aurora RDS (from a bastion or local machine with psql access) |
68 | | -pg_dump -Fc -h your-cluster.cluster-xxxx.us-east-1.rds.amazonaws.com \ |
69 | | - -U vulcan_user -d vulcan_production > vulcan_backup_$(date +%Y%m%d).dump |
| 58 | +# 2. Pull new code |
| 59 | +cd /path/to/vulcan && git pull |
70 | 60 |
|
71 | | -# Docker Compose |
72 | | -docker compose exec db pg_dump -Fc -U postgres vulcan_postgres_production \ |
73 | | - > vulcan_backup_$(date +%Y%m%d).dump |
| 61 | +# 3. Preflight |
| 62 | +bundle exec rails upgrade:preflight |
74 | 63 |
|
75 | | -# ECS / Kubernetes (exec into the db container or use a bastion) |
76 | | -kubectl exec -it deploy/vulcan-db -- pg_dump -Fc -U postgres vulcan_production \ |
77 | | - > vulcan_backup_$(date +%Y%m%d).dump |
| 64 | +# 4. Fix |
| 65 | +bundle exec rails upgrade:fix |
| 66 | + |
| 67 | +# 5. Upgrade |
| 68 | +bundle exec rails db:prepare |
| 69 | + |
| 70 | +# 6. Verify |
| 71 | +bundle exec rails upgrade:verify |
78 | 72 | ``` |
79 | 73 |
|
80 | | -### Step 3: Run the preflight check |
| 74 | +### Can't even connect? (quick diagnostic) |
| 75 | + |
| 76 | +If the new container won't start at all, use the standalone script from any machine with `psql`: |
81 | 77 |
|
82 | 78 | ```bash |
83 | | -# Bare metal / systemd |
84 | | -bundle exec rails upgrade:preflight |
| 79 | +curl -fsSL https://raw.githubusercontent.com/mitre/vulcan/master/bin/upgrade-check.sh -o upgrade-check.sh |
| 80 | +chmod +x upgrade-check.sh |
| 81 | +./upgrade-check.sh "postgres://user:pass@your-db-host:5432/vulcan_production?sslmode=require" |
| 82 | +``` |
85 | 83 |
|
86 | | -# Docker Compose |
87 | | -docker compose exec web rails upgrade:preflight |
| 84 | +No Rails, no Ruby, no container — just raw database diagnostics. |
88 | 85 |
|
89 | | -# Docker (new image against existing database) |
90 | | -docker run --rm --env-file .env vulcan:new-version rails upgrade:preflight |
| 86 | +### What the tools do |
91 | 87 |
|
92 | | -# ECS / Kubernetes |
93 | | -kubectl exec -it deploy/vulcan-web -- rails upgrade:preflight |
94 | | -``` |
| 88 | +| Command | When | What | |
| 89 | +|---|---|---| |
| 90 | +| `rails upgrade:preflight` | Before upgrade | Checks connectivity, SSL, schema, orphaned data, config (read-only) | |
| 91 | +| `rails upgrade:fix` | Before upgrade | Fixes orphaned records, counter caches, missing dirs (safe writes) | |
| 92 | +| `rails upgrade:verify` | After upgrade | Validates schema, models, routes, assets, admin user | |
| 93 | +| `bin/upgrade-check.sh` | Can't start container | Raw psql diagnostic — tests connection, SSL, encoding | |
95 | 94 |
|
96 | 95 | The preflight reports: |
97 | 96 | - ✓ = good |
98 | 97 | - ⚠ = warning (review, but won't block) |
99 | 98 | - ✗ = blocker (must fix before upgrading) |
100 | 99 |
|
101 | | -### Step 4: Fix any issues |
102 | | - |
103 | | -```bash |
104 | | -# Auto-fix safe issues (orphaned records, counter caches, missing dirs) |
105 | | -bundle exec rails upgrade:fix |
106 | | - |
107 | | -# Or in Docker |
108 | | -docker compose exec web rails upgrade:fix |
109 | | -``` |
110 | | - |
111 | | -The fix task only runs **safe operations** — it will NOT: |
112 | | -- Delete data without telling you exactly what and how many rows |
113 | | -- Modify schema (that's what db:prepare does) |
114 | | -- Change configuration (it tells you what to set) |
115 | | - |
116 | | -For connection issues (the most common upgrade blocker), the fix task prints the exact environment variables you need to set. |
| 100 | +### Upgrading from pre-v2.3.6 (toolkit not in image) |
117 | 101 |
|
118 | | -### Step 5: Run the upgrade |
| 102 | +If your CURRENT image doesn't have the toolkit yet, run the preflight from the NEW image: |
119 | 103 |
|
120 | 104 | ```bash |
121 | | -# This runs pending migrations (safe — preflight already validated) |
122 | | -bundle exec rails db:prepare |
| 105 | +# Pull the new image but don't start it yet |
| 106 | +docker pull mitre/vulcan:v2.3.6 |
123 | 107 |
|
124 | | -# Docker: the entrypoint does this automatically on container start |
125 | | -docker compose up |
| 108 | +# Run preflight from the new image against your existing database |
| 109 | +docker run --rm --env-file .env mitre/vulcan:v2.3.6 rails upgrade:preflight |
| 110 | +docker run --rm --env-file .env mitre/vulcan:v2.3.6 rails upgrade:fix |
126 | 111 | ``` |
127 | 112 |
|
128 | | -### Step 6: Verify |
129 | | - |
130 | | -```bash |
131 | | -bundle exec rails upgrade:verify |
132 | | -# or |
133 | | -docker compose exec web rails upgrade:verify |
134 | | -``` |
| 113 | +The `--env-file .env` passes your existing database credentials to the new container. |
135 | 114 |
|
136 | 115 | --- |
137 | 116 |
|
|
0 commit comments