feat: add individual and bulk chart upgrade, fix health check URL
All checks were successful
Build & Release / build (push) Successful in 12s

This commit is contained in:
Ryan Moon
2026-04-03 21:26:35 -05:00
parent 766ad63278
commit 31684f4a15
4 changed files with 84 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ import crypto from "crypto";
import postgres from "postgres";
import { createDatabase, createDatabaseUser, deleteDatabase, deleteDatabaseUser } from "../services/do";
import { addCustomerToPool, removeCustomerFromPool } from "../services/pgbouncer";
import { addCustomerChart, removeCustomerChart } from "../services/git";
import { addCustomerChart, removeCustomerChart, upgradeCustomerChart, upgradeAllCustomerCharts, getLatestChartVersion } from "../services/git";
import { setupCustomerDatabase, teardownCustomerDatabase } from "../services/db";
import { createNamespace, deleteNamespace, createSecret, createDockerRegistrySecret, patchSecret, getSecret, k8sFetch } from "../lib/k8s";
import { deleteSpacesObjects, getSpacesUsage } from "../services/spaces";
@@ -305,6 +305,27 @@ export async function customerRoutes(app: FastifyInstance) {
return reply.code(200).send({ slug, status: "provisioned" });
});
app.post("/customers/:slug/upgrade", async (req, reply) => {
const { slug } = req.params as { slug: string };
const [customer] = await db`SELECT * FROM customers WHERE slug = ${slug}`;
if (!customer) return reply.code(404).send({ message: "Not found" });
const version = await getLatestChartVersion();
await upgradeCustomerChart(slug, version);
await db`UPDATE customers SET updated_at = NOW() WHERE slug = ${slug}`;
app.log.info({ slug, version }, "customer chart upgraded");
return reply.send({ slug, version });
});
app.post("/customers/upgrade-all", async (req, reply) => {
const customers = await db`SELECT slug FROM customers WHERE status = 'provisioned'`;
if (!customers.length) return reply.send({ upgraded: [], version: null });
const version = await getLatestChartVersion();
const slugs = customers.map((c: any) => c.slug);
await upgradeAllCustomerCharts(slugs, version);
app.log.info({ slugs, version }, "all customers chart upgraded");
return reply.send({ upgraded: slugs, version });
});
// Remove only the manager DB record without touching infrastructure
app.delete("/customers/:slug/record", async (req, reply) => {
const { slug } = req.params as { slug: string };