Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
npm-debug.log*
coverage/
dist/
test/fixtures/golden/
8 changes: 8 additions & 0 deletions src/adapters/kubernetes-workload-fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ function buildWorkloadManifest(workload: WorkloadV2, ns: string, images: Record<
};
}

/** TTL after job completion (Option B decision). Allows Flux to re-apply a
* new Job after the previous one is automatically cleaned up, avoiding
* AlreadyExists conflicts on reconciliation. Value must exceed the Flux
* reconciliation interval + health-check scrape window; 3600 s (1 h) is
* the owner-decided value (DECISIONS.md 2026-07-12). */
const JOB_TTL_SECONDS_AFTER_FINISHED = 3600;

function buildJobManifest(workload: WorkloadV2, ns: string, images: Record<string, string>): K8sManifest {
const podSpec: Record<string, unknown> = {
serviceAccountName: workload.name,
Expand All @@ -135,6 +142,7 @@ function buildJobManifest(workload: WorkloadV2, ns: string, images: Record<strin
kind: "Job",
metadata: { name: workload.name, namespace: ns, labels: jobLabels(workload) },
spec: {
ttlSecondsAfterFinished: JOB_TTL_SECONDS_AFTER_FINISHED,
template: { metadata: { labels: jobLabels(workload) }, spec: podSpec },
},
};
Expand Down
3 changes: 3 additions & 0 deletions test/fragment-engine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ test("job workload: kubernetes fragment renders batch/v1 Job with migration labe
assert.equal(job.metadata.labels["app.kubernetes.io/component"], "migration",
"Job must carry app.kubernetes.io/component=migration for prune-guardrails");
assert.equal(job.spec.template.spec.restartPolicy, "Never");
// TTL: Option B (owner decision 2026-07-12) — completed jobs must be cleaned up automatically
assert.equal(job.spec.ttlSecondsAfterFinished, 3600,
"Job must carry ttlSecondsAfterFinished:3600 so Flux can re-apply after cleanup");
// No PVCs in output
assert.ok(!rendered.manifests.some((m) => m.kind === "PersistentVolumeClaim"),
"Job workload must not emit PVCs");
Expand Down