Add RenderStatus to the Kptfile for per-function pipeline result tracking#4437
Add RenderStatus to the Kptfile for per-function pipeline result tracking#4437aravindtga wants to merge 1 commit intokptdev:mainfrom
Conversation
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
e9f6347 to
3c93572
Compare
Signed-off-by: aravind.est <aravindhan.a@est.tech>
3c93572 to
13ed78f
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the root Kptfile status to include a structured renderStatus after kpt fn render, enabling per-function pipeline step result tracking (mutation + validation) and updating E2E fixtures accordingly.
Changes:
- Add
status.renderStatus(mutationSteps/validationSteps/errorSummary) to theKptfilev1 API types. - Track and persist per-step execution details during render, and write them into the root
Kptfilefor in-place renders. - Make E2E diff comparisons more resilient by allowing regex-based stripping/normalization of diff output.
Reviewed changes
Copilot reviewed 137 out of 138 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/api/kptfile/v1/types.go |
Adds Status.RenderStatus and supporting status/result schema types. |
internal/util/render/executor.go |
Captures per-function step results during render and writes renderStatus into the root Kptfile on in-place renders. |
internal/util/render/executor_test.go |
Adds unit tests for renderStatus building and result capture/conversion. |
pkg/test/runner/config.go |
Adds diffStripRegEx test config knob for diff normalization. |
pkg/test/runner/runner.go |
Normalizes diffs (strip + header normalization) before comparing expected vs actual diffs. |
e2e/testdata/fn-render/**/.expected/diff.patch (many files) |
Updates expected diffs to include the new status.renderStatus output. |
e2e/testdata/fn-render/**/.expected/config.yaml (some files) |
Adjusts expected configs to use diffStripRegEx (and related stderr matching changes). |
e2e/testdata/fn-render/**/starlark-fn-failure.yaml (some files) |
Adds fixtures to reliably force function failure for renderStatus failure-path expectations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mutators, err := fnChain(ctx, hctx, pn.pkg.UniquePath, pl.Mutators) | ||
| if err != nil { | ||
| // Capture execution error (e.g. missing exec, image resolution failure) | ||
| hctx.mutationSteps = append(hctx.mutationSteps, executionErrorStep(pl.Mutators, err)) | ||
| return nil, err |
There was a problem hiding this comment.
When fnChain returns an error, runMutators records an executionErrorStep using the entire pl.Mutators list, but executionErrorStep always uses the first function in the list. This can misattribute the failure to the wrong mutator (e.g. if the 2nd+ function fails image resolution or is an exec step disallowed by --allow-exec). Consider changing fnChain to return which Function failed (or returning a partial slice + failing index) so the RenderStatus step result accurately identifies the failing mutator.
| func normalizeDiff(diff, stripRegEx string) string { | ||
| re := regexp.MustCompile(stripRegEx) | ||
| indexRE := regexp.MustCompile(`^index [0-9a-f]+\.\.[0-9a-f]+`) | ||
| hunkRE := regexp.MustCompile(`^@@ -\d+,\d+ \+\d+,\d+ @@`) | ||
| var out []string | ||
| for _, line := range strings.Split(diff, "\n") { | ||
| if re.MatchString(line) { | ||
| continue | ||
| } | ||
| line = indexRE.ReplaceAllString(line, "index NORMALIZED") | ||
| line = hunkRE.ReplaceAllString(line, "@@ NORMALIZED @@") | ||
| out = append(out, line) | ||
| } | ||
| return strings.Join(out, "\n") |
There was a problem hiding this comment.
normalizeDiff uses regexp.MustCompile(stripRegEx), which will panic (and crash the whole test run) if a test config provides an invalid regex. Consider compiling with regexp.Compile and returning an error that compareResult can surface (similar to compareOutput’s StdErrRegEx handling), rather than panicking.
After every kpt fn render execution, a structured renderStatus is now recorded in the root Kptfile alongside the existing Rendered condition, providing per-function pipeline result tracking.
Note
76 of the 79 changed files are E2E test fixture updates
(e2e/testdata/fn-render/**/.expected/diff.patch). The core implementation changes are in 3 files.What
Fixes: #4390
Success case:
Failure case:
Behaviour
Tests