Skip to content

Commit 6795c1f

Browse files
committed
Debug migration
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
1 parent ddd694a commit 6795c1f

1 file changed

Lines changed: 87 additions & 3 deletions

File tree

.github/workflows/cancel-pulumi-lock.yml

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ on:
1010
options:
1111
- staging
1212
- production
13+
action:
14+
description: 'Action to perform'
15+
required: true
16+
type: choice
17+
options:
18+
- cancel-pulumi-lock
19+
- check-migrations
1320

1421
permissions:
1522
contents: read
@@ -56,7 +63,7 @@ jobs:
5663
project_id: mcp-registry-prod
5764

5865
- name: Cancel Pulumi Lock (Staging)
59-
if: inputs.environment == 'staging'
66+
if: inputs.environment == 'staging' && inputs.action == 'cancel-pulumi-lock'
6067
working-directory: ./deploy
6168
env:
6269
PULUMI_STAGING_PASSPHRASE: ${{ secrets.PULUMI_STAGING_PASSPHRASE }}
@@ -66,11 +73,88 @@ jobs:
6673
PULUMI_CONFIG_PASSPHRASE_FILE=passphrase.staging.txt pulumi cancel --stack gcpStaging --yes
6774
6875
- name: Cancel Pulumi Lock (Production)
69-
if: inputs.environment == 'production'
76+
if: inputs.environment == 'production' && inputs.action == 'cancel-pulumi-lock'
7077
working-directory: ./deploy
7178
env:
7279
PULUMI_PROD_PASSPHRASE: ${{ secrets.PULUMI_PROD_PASSPHRASE }}
7380
run: |
7481
echo "$PULUMI_PROD_PASSPHRASE" > passphrase.prod.txt
7582
pulumi login gs://mcp-registry-prod-pulumi-state
76-
PULUMI_CONFIG_PASSPHRASE_FILE=passphrase.prod.txt pulumi cancel --stack gcpProd --yes
83+
PULUMI_CONFIG_PASSPHRASE_FILE=passphrase.prod.txt pulumi cancel --stack gcpProd --yes
84+
85+
- name: Configure kubectl (Staging)
86+
if: inputs.environment == 'staging' && inputs.action == 'check-migrations'
87+
run: |
88+
gcloud container clusters get-credentials mcp-registry-staging \
89+
--zone=us-central1-b \
90+
--project=mcp-registry-staging
91+
gcloud components install gke-gcloud-auth-plugin
92+
93+
- name: Configure kubectl (Production)
94+
if: inputs.environment == 'production' && inputs.action == 'check-migrations'
95+
run: |
96+
gcloud container clusters get-credentials mcp-registry-prod \
97+
--zone=us-central1-b \
98+
--project=mcp-registry-prod
99+
gcloud components install gke-gcloud-auth-plugin
100+
101+
- name: Check Migrations
102+
if: inputs.action == 'check-migrations'
103+
run: |
104+
echo "=== Getting postgres pod name ==="
105+
POD_NAME=$(kubectl get pods -l cnpg.io/cluster=registry-pg -n default -o jsonpath='{.items[0].metadata.name}')
106+
echo "Found postgres pod: $POD_NAME"
107+
108+
echo ""
109+
echo "=== ALL Applied Migrations in ${{ inputs.environment }} ==="
110+
kubectl exec -n default $POD_NAME -- \
111+
psql -U app -d app -c "SELECT version, name, applied_at FROM schema_migrations ORDER BY version;"
112+
113+
echo ""
114+
echo "=== Checking for migration 009 specifically ==="
115+
MIGRATION_009_COUNT=$(kubectl exec -n default $POD_NAME -- \
116+
psql -U app -d app -tAc "SELECT COUNT(*) FROM schema_migrations WHERE version = 9;" | tr -d '[:space:]')
117+
118+
if [ "$MIGRATION_009_COUNT" = "0" ]; then
119+
echo "❌ Migration 009 NOT FOUND - this explains why packages still have old format"
120+
else
121+
echo "✅ Migration 009 IS APPLIED"
122+
fi
123+
124+
echo ""
125+
echo "=== Sample Package Data (first 3 servers with packages) ==="
126+
kubectl exec -n default $POD_NAME -- \
127+
psql -U app -d app -c "
128+
SELECT
129+
server_name,
130+
jsonb_pretty(value->'packages') as packages
131+
FROM servers
132+
WHERE value ? 'packages'
133+
AND jsonb_array_length(value->'packages') > 0
134+
LIMIT 3;
135+
"
136+
137+
echo ""
138+
echo "=== Database Schema/Layout ==="
139+
kubectl exec -n default $POD_NAME -- \
140+
psql -U app -d app -c "\dt+"
141+
142+
echo ""
143+
echo "=== Schema for 'servers' table ==="
144+
kubectl exec -n default $POD_NAME -- \
145+
psql -U app -d app -c "\d+ servers"
146+
147+
echo ""
148+
echo "=== Schema for 'schema_migrations' table ==="
149+
kubectl exec -n default $POD_NAME -- \
150+
psql -U app -d app -c "\d+ schema_migrations"
151+
152+
echo ""
153+
echo "=== Registry Server Logs (first 100 lines) ==="
154+
REGISTRY_POD=$(kubectl get pods -l app=mcp-registry -n default -o jsonpath='{.items[0].metadata.name}')
155+
if [ -n "$REGISTRY_POD" ]; then
156+
echo "Found registry pod: $REGISTRY_POD"
157+
kubectl logs -n default $REGISTRY_POD --tail=100
158+
else
159+
echo "⚠️ No registry pod found"
160+
fi

0 commit comments

Comments
 (0)