Files
trebuchet/apps/api/src/services/job-manager.ts
T
Chris Farhood 7b16bf98f7 refactor: rename custom components from shannon-* to hightower-*
Renames API server, worker jobs, credentials secret, and workspaces
PVC to use the hightower prefix. Upstream Shannon names (namespace,
Temporal service, package imports, .shannon/ dir) are unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-20 09:09:34 -04:00

36 lines
1.0 KiB
TypeScript

/**
* K8s Job lifecycle management — create, delete, list worker Jobs.
*/
import type * as k8s from '@kubernetes/client-node';
const WORKER_LABEL = 'hightower-worker';
export async function createJob(batchApi: k8s.BatchV1Api, namespace: string, job: k8s.V1Job): Promise<void> {
await batchApi.createNamespacedJob({ namespace, body: job });
}
export async function deleteJob(batchApi: k8s.BatchV1Api, namespace: string, name: string): Promise<void> {
await batchApi.deleteNamespacedJob({
name,
namespace,
propagationPolicy: 'Background',
});
}
export async function getJob(batchApi: k8s.BatchV1Api, namespace: string, name: string): Promise<k8s.V1Job | null> {
try {
return await batchApi.readNamespacedJob({ name, namespace });
} catch {
return null;
}
}
export async function listWorkerJobs(batchApi: k8s.BatchV1Api, namespace: string): Promise<k8s.V1Job[]> {
const response = await batchApi.listNamespacedJob({
namespace,
labelSelector: `app=${WORKER_LABEL}`,
});
return response.items;
}