vibecarbon 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -844,6 +844,24 @@ export async function setupReplication(options) {
|
|
|
844
844
|
),
|
|
845
845
|
);
|
|
846
846
|
|
|
847
|
+
// Mirror of reloadPostgrest() in the base k8s path. The rollout-restart of
|
|
848
|
+
// supabase-supabase-rest above already refreshes its schema cache, but issue
|
|
849
|
+
// the canonical NOTIFY explicitly so the app tables stay visible to PostgREST
|
|
850
|
+
// even if that restart list ever changes — same PGRST205 class the base
|
|
851
|
+
// deploy guards against. Best-effort (ignoreError): a missed reload
|
|
852
|
+
// self-heals on the next rest restart.
|
|
853
|
+
await perfAsync('deploy.ha.replication.reloadPostgrest', () =>
|
|
854
|
+
runCommandAsync(
|
|
855
|
+
[
|
|
856
|
+
'ssh',
|
|
857
|
+
...sshOpts,
|
|
858
|
+
`root@${primaryIp}`,
|
|
859
|
+
`kubectl exec -i -n vibecarbon supabase-supabase-db-0 -- psql -U supabase_admin -d postgres -c "NOTIFY pgrst, 'reload schema'"`,
|
|
860
|
+
],
|
|
861
|
+
{ silent: true, ignoreError: true },
|
|
862
|
+
),
|
|
863
|
+
);
|
|
864
|
+
|
|
847
865
|
// 4. Initialize standby as a streaming replica of the primary.
|
|
848
866
|
// Modeled after standby-init.sh — runs pg_basebackup directly inside the standby pod
|
|
849
867
|
// connecting to the primary's supabase node via hostPort 5432 (the Hetzner Cloud firewall
|
|
@@ -1525,6 +1525,52 @@ export async function applyMigrations({ kubeconfig, projectDir }) {
|
|
|
1525
1525
|
}
|
|
1526
1526
|
}
|
|
1527
1527
|
|
|
1528
|
+
/**
|
|
1529
|
+
* Reload PostgREST's schema cache after applyMigrations.
|
|
1530
|
+
*
|
|
1531
|
+
* The chart's `rest` (supabase-supabase-rest) pod comes up during helm
|
|
1532
|
+
* `--wait`, BEFORE applyMigrations runs — so its in-memory schema cache
|
|
1533
|
+
* predates the app tables. Reads of /rest/v1/<table> then 404 with PGRST205
|
|
1534
|
+
* ("Could not find the table ... in the schema cache") until PostgREST
|
|
1535
|
+
* reloads. No DDL-watch event trigger exists in the app migrations or db init
|
|
1536
|
+
* to auto-NOTIFY (verified), so issue the canonical reload explicitly.
|
|
1537
|
+
*
|
|
1538
|
+
* This is the k8s mirror of the compose fix (compose/index.js): same intent —
|
|
1539
|
+
* `NOTIFY pgrst, 'reload schema'` on the db — via `kubectl exec` instead of
|
|
1540
|
+
* `docker compose exec`. Best-effort: a missed reload self-heals whenever the
|
|
1541
|
+
* rest pod next restarts (e.g. the k8s-ha replication path rollout-restarts it
|
|
1542
|
+
* anyway), so a failure here is logged, not fatal.
|
|
1543
|
+
*
|
|
1544
|
+
* @param {{kubeconfig: string}} args
|
|
1545
|
+
*/
|
|
1546
|
+
export async function reloadPostgrest({ kubeconfig }) {
|
|
1547
|
+
const env = { ...process.env, KUBECONFIG: kubeconfig };
|
|
1548
|
+
const { status, stderr } = await execKubectlOnce(
|
|
1549
|
+
[
|
|
1550
|
+
'-n',
|
|
1551
|
+
'vibecarbon',
|
|
1552
|
+
'exec',
|
|
1553
|
+
'-i',
|
|
1554
|
+
'--request-timeout=15s',
|
|
1555
|
+
'supabase-supabase-db-0',
|
|
1556
|
+
'--',
|
|
1557
|
+
'psql',
|
|
1558
|
+
'-U',
|
|
1559
|
+
'supabase_admin',
|
|
1560
|
+
'-d',
|
|
1561
|
+
'postgres',
|
|
1562
|
+
'-c',
|
|
1563
|
+
"NOTIFY pgrst, 'reload schema'",
|
|
1564
|
+
],
|
|
1565
|
+
{ env, killAfterMs: 20_000 },
|
|
1566
|
+
);
|
|
1567
|
+
if (status !== 0) {
|
|
1568
|
+
console.log(
|
|
1569
|
+
`[migrate] PostgREST schema reload NOTIFY failed (non-fatal, self-heals on rest restart): ${(stderr || '').trim().slice(-200)}`,
|
|
1570
|
+
);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1528
1574
|
/**
|
|
1529
1575
|
* Apply cert-manager + vibecarbon-secrets + the project's k8s/infra +
|
|
1530
1576
|
* k8s/base kustomizations, install supabase via helm, patch the app
|
|
@@ -2133,6 +2179,13 @@ export async function applyK3sManifests({
|
|
|
2133
2179
|
await perfAsync(`deploy.${perfPrefix}.applyMigrations`, async () =>
|
|
2134
2180
|
applyMigrations({ kubeconfig, projectDir }),
|
|
2135
2181
|
);
|
|
2182
|
+
// 8b. Reload PostgREST's schema cache so it sees the tables applyMigrations
|
|
2183
|
+
// just created. rest came up during helm --wait (before migrations) and
|
|
2184
|
+
// no DDL-watch trigger exists to auto-NOTIFY — without this, /rest/v1/*
|
|
2185
|
+
// 404s with PGRST205 until rest restarts. Mirrors the compose fix.
|
|
2186
|
+
await perfAsync(`deploy.${perfPrefix}.reloadPostgrest`, async () =>
|
|
2187
|
+
reloadPostgrest({ kubeconfig }),
|
|
2188
|
+
);
|
|
2136
2189
|
// 9. Wait for app rollout. The deployment template already has
|
|
2137
2190
|
// imagePullPolicy: IfNotPresent, so kubelet uses the sideloaded image
|
|
2138
2191
|
// without pulling. 300s wasn't enough on a cold deploy where the app
|