fix(runner): stamp Workflow ownerRef on applied SeiNodeTask CRs#350
Conversation
The runner subcommand was the last seitask command not stamping the parent Workflow's ownerRef on what it creates. provision-snd, keygen, and EnsureWorkflowVarsCM already do; runner-applied SeiNodeTask CRs silently leaked across runs because no ownerRef linked them to the Workflow lifecycle. Add an OwnerRef field to DefaultRenderer; populate it from taskruntime.LoadWorkflowIdentity at subcommand startup; replace (not merge) ownerReferences on the rendered manifest before SSA. Mirrors provisionsnd.stampMetadata exactly so a template-smuggled bogus ref can't leak through. With this in place, deleting the Workflow CR cascades the per-run SeiNodeTask CRs along with the existing SND + workflow-vars CM + admin Secret. The platform-side gc-cronjob can sweep just Workflows; cascade reaps the rest. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 906e520. Bugbot is set up for automated code reviews on this repo. Configure here. |
… on runner Task containers (#351) #350 made taskruntime.LoadWorkflowIdentity mandatory at runner startup so applied SeiNodeTask CRs get a Workflow ownerRef. LoadWorkflowIdentity reads SEI_WORKFLOW_NAME + SEI_NAMESPACE from env (downward API). The keygen/provision-snd/upload-report Task containers already project these via downward API, but the 12 `runner` Task containers in scenarios/major-upgrade.yaml did NOT — pre-#350 the runner didn't need them. Result: every runner step in major-upgrade exits 2 with `seitask: infra: downward-API env not projected: [SEI_WORKFLOW_NAME SEI_NAMESPACE]` before doing any work. The gov pipeline silently failed end-to-end on the first post-#350 fire even though chaos-mesh reported the Workflow Accomplished (because chaos-mesh Accomplished doesn't mean container exit 0). Add the env block to all 12 runner Task containers. scenarios/release-test and scenarios/load-test don't invoke `runner`, so they're unaffected. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Closes the last gap in the workflow ownership chain. Before this change, the seitask
runnersubcommand applied SeiNodeTask CRs via SSA but never stamped an ownerRef pointing at the parent Workflow — so per-run SNTs survived workflow deletion and accumulated indefinitely across nightly runs.keygen,provision-snd, andtaskruntime.EnsureWorkflowVarsCMalready stamp the Workflow ownerRef on what they create. This PR bringsrunnerin line with that pattern:OwnerRef *metav1.OwnerReferencetorunner.DefaultRenderer.cmd/seitask/runner.go, calltaskruntime.LoadWorkflowIdentity(ctx, cliClient)at subcommand startup; pass&wf.OwnerRef()into the renderer.RenderBytes, replace (not merge)metadata.ownerReferencesso a template-smuggled bogus ref can't leak through — mirrorsprovisionsnd.stampMetadataexactly.Result:
kubectl delete workflow major-upgrade-<run-id>(or the gc-cronjob age sweep at 24h) cascades to every per-run resource — SND, workflow-vars CM, admin Secret, SeiNodeTasks, Task pods.Test plan
TestRenderBytes_StampsOwnerRefcovers both the stamping path (single Workflow ref replaces any template-declared refs) and the nil-ownerRef path (template-declared refs preserved for backward compat).go test ./...passes.kubectl get snt -o yaml | grep -A3 ownerReferences).Related
🤖 Generated with Claude Code