Skip to content

Commit 0137314

Browse files
feat(job-workload): add ttlSecondsAfterFinished:3600 to rendered Job manifests (#43)
1 parent c7acc55 commit 0137314

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/
22
npm-debug.log*
33
coverage/
44
dist/
5+
test/fixtures/golden/

src/adapters/kubernetes-workload-fragment.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ function buildWorkloadManifest(workload: WorkloadV2, ns: string, images: Record<
118118
};
119119
}
120120

121+
/** TTL after job completion (Option B decision). Allows Flux to re-apply a
122+
* new Job after the previous one is automatically cleaned up, avoiding
123+
* AlreadyExists conflicts on reconciliation. Value must exceed the Flux
124+
* reconciliation interval + health-check scrape window; 3600 s (1 h) is
125+
* the owner-decided value (DECISIONS.md 2026-07-12). */
126+
const JOB_TTL_SECONDS_AFTER_FINISHED = 3600;
127+
121128
function buildJobManifest(workload: WorkloadV2, ns: string, images: Record<string, string>): K8sManifest {
122129
const podSpec: Record<string, unknown> = {
123130
serviceAccountName: workload.name,
@@ -135,6 +142,7 @@ function buildJobManifest(workload: WorkloadV2, ns: string, images: Record<strin
135142
kind: "Job",
136143
metadata: { name: workload.name, namespace: ns, labels: jobLabels(workload) },
137144
spec: {
145+
ttlSecondsAfterFinished: JOB_TTL_SECONDS_AFTER_FINISHED,
138146
template: { metadata: { labels: jobLabels(workload) }, spec: podSpec },
139147
},
140148
};

test/fragment-engine.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,9 @@ test("job workload: kubernetes fragment renders batch/v1 Job with migration labe
522522
assert.equal(job.metadata.labels["app.kubernetes.io/component"], "migration",
523523
"Job must carry app.kubernetes.io/component=migration for prune-guardrails");
524524
assert.equal(job.spec.template.spec.restartPolicy, "Never");
525+
// TTL: Option B (owner decision 2026-07-12) — completed jobs must be cleaned up automatically
526+
assert.equal(job.spec.ttlSecondsAfterFinished, 3600,
527+
"Job must carry ttlSecondsAfterFinished:3600 so Flux can re-apply after cleanup");
525528
// No PVCs in output
526529
assert.ok(!rendered.manifests.some((m) => m.kind === "PersistentVolumeClaim"),
527530
"Job workload must not emit PVCs");

0 commit comments

Comments
 (0)