Repository navigation
fix(trigger): keep the kro trigger Job update-safe across RGD releases - #52
Merged
Merged
Conversation
6 of 14 tasks
kro applies every RGD change to every existing instance, including the Job of a CR that finished long ago. A Job's spec.template is immutable, so a new trigger script in the Job's command (e.g. #50's retried GET) put every existing ClusterBuildWatch / BackstageTemplateRun into ERROR: Job.batch "<name>" is invalid: spec.template: ... field is immutable Both RGDs now keep everything a release may change out of the Job: - start.sh, input.json and not-after live in the <name>-input ConfigMap, which kro updates in place. The Job only runs `sh /input/start.sh`; a Job that has run is never touched again. - What can still change in the pod template -- the CR's triggerImage and a "trigger-v1" marker for the template itself -- is hashed into the Job name (<name>-<8 hex>). A change yields a new Job, kro prunes the old one, and the new Job's GET finds the instance and exits 0. The rename also migrates existing instances: their old Job <name> is pruned, the new one finds the instance, and CRs in ERROR recover. Start-once is unchanged (GET first, POST only on a clean ERR_INSTANCE_ID_NOT_FOUND, POST never retried). notAfter now reaches the script as a file instead of an env var. CR names are limited to 54 characters by the suffix. Verified on a throwaway kind cluster with kro v0.9.4 (same as test5) and a mock dapr endpoint counting start POSTs. Refs #49 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
patrick-hermann-sva
force-pushed
the
fix/rgd-immutable-job
branch
from
October 20, 2026 18:15
53f4ebe to
40df1af
Compare
patrick-hermann-sva
had a problem deploying
to
linting
October 20, 2026 18:15 — with
GitHub Actions
Failure
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Follow-up to #49 ("Befund nach der Flux-Übernahme"). kro applies every RGD change to every existing instance, including the Job of a CR that finished long ago. A Job's
spec.templateis immutable. So any new trigger script in the Job'scommand(e.g. the retried GET from #50) puts every existingClusterBuildWatch/BackstageTemplateRunintoERROR:kro v0.9.4 (the version on test5) has no create-only, ignore-field or skip-update option for a managed resource. The applyset always does SSA with
Force: true, and the only per-resource switches areincludeWhen,readyWhenandexternalRef.Fix (both RGDs)
start.sh,input.jsonandnot-afterlive in the<name>-inputConfigMap, which kro updates in place. The Job runs onlysh /input/start.sh. A script change touches no Job and runs nothing.triggerImageplus atrigger-v1marker for the template itself. The name becomes<name>-<first 8 hex of sha256>. A change creates a new Job and kro prunes the old one. The new Job's GET finds the instance and exitsalready exists, not starting it again, the same path as a Job deleted by hand. A newtriggerImagedefault never reaches existing CRs, because the API server stored the default in each CR.ERR_INSTANCE_ID_NOT_FOUND, POST never retried,notAfterchecked first.notAfternow reaches the script as a file instead of an env var (still free text, never spliced into the script).<name>, which is no longer desired, so kro prunes it and creates<name>-<hash>. That Job finds the instance and exits 0. CRs already inERRORrecover by themselves.READMEs and RGD comments explain the rule: changing anything else in the Job's pod template requires bumping
trigger-v1.Rejected alternatives
includeWhenon instance or Job status: a resource cannot reference its own status. A flip tofalseprunes the Job, andstatus.jobName/succeededlose their source. The kro docs warn against flip-flop.Trade-offs
must be no more than 63 bytes) and start nothing. Backstagerequest-vmproducesvm-<≤40>/delete-vm-<…>, which fits.trigger-v1bump ortriggerImageedit) asks the sidecar once more. Like any recreated Job, it starts again only if the state store has forgotten the instance andnotAfterhas not passed.Test evidence (throwaway kind cluster
kro-rgd-test, krov0.9.4= test5, mock dapr endpoint counting start POSTs)app-oldcreatedapp-old→ERROR,Job.batch "app-old" is invalid: spec.template ... immutableapp-old→ACTIVE; Jobapp-oldpruned,app-old-c5d8a89elogsinstance cbw_app-old already exists, not starting it again; starts still 1app-newnotAfter,pollSeconds)triggerImagedefault bumpedtriggerImageeditedapp-old-c5d8a79e, old pruned,already exists, starts still 1already exists, starts still 1 eachalready exists, no startmust be no more than 63 bytes, nothing startednotAfter, withwatch)vm-demo-1recovered, POST count 1; pastnotAfter→has passed, not starting;vm-demo-3POST body incl.watchas beforeFinal mock counters:
{"cbw_app-old": 1, "cbw_app-new": 1, "cbw_aaaa…": 1, "bst_vm-demo-1": 1, "bst_vm-demo-3": 1}. Every instance was started exactly once.Checks:
pre-commit run --fileson the changed files (check-yaml, detect-secrets, …) passed; YAML parses; the extractedstart.shpassesshellcheck -s shwith the kro expressions stubbed. Both RGDs:GraphAccepted=True, revision compiled on kro v0.9.4.Rollout note
Live on test5 right now: 1 instance (
cluster-build-watch/app-dev-homerun, ACTIVE). After the next release it gets Jobapp-dev-homerun-<hash>(logsalready exists), and the old Jobapp-dev-homerunis pruned. Its pod remains as an ownerless Completed pod.Refs #49
🤖 Generated with Claude Code