Skip to content

Add RenderStatus to the Kptfile for per-function pipeline result tracking#4437

Draft
aravindtga wants to merge 1 commit intokptdev:mainfrom
Nordix:add_render_status_details_on_kptfile
Draft

Add RenderStatus to the Kptfile for per-function pipeline result tracking#4437
aravindtga wants to merge 1 commit intokptdev:mainfrom
Nordix:add_render_status_details_on_kptfile

Conversation

@aravindtga
Copy link
Contributor

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

  • Add a renderStatus field to status in the root Kptfile after render
  • Track per-function results for both mutation and validation pipeline steps
  • Each PipelineStepResult captures: function name/image/exec, exit code, stderr, structured results, and error-only results
  • On failure: an errorSummary aggregates which steps failed and why

Fixes: #4390

Success case:

status:
  conditions:
    - type: Rendered
      status: "True"
      reason: renderSucceeded
  renderStatus:
    mutationSteps:
      - image: gcr.io/kpt-fn/set-namespace:v0.4.5
        exitCode: 0
    validationSteps:
      - image: gcr.io/kpt-fn/gatekeeper:v0.2.1
        exitCode: 0

Failure case:

status:
  conditions:
    - type: Rendered
      status: "False"
      reason: renderFailed
      message: "pipeline failed"
  renderStatus:
    mutationSteps:
      - image: set-namespace:v1
        exitCode: 0
    validationSteps:
      - image: gatekeeper:latest
        exitCode: 1
        stderr: "validation failed"
    errorSummary: "gatekeeper:latest: exit code 1"

Behaviour

  • In-place render (kpt fn render): renderStatus is written to the Kptfile
  • Out-of-place / stdout / unwrap mode (kpt fn render -o <dir|stdout|unwrap>): renderStatus is not written since there is no on-disk package to update

Tests

  • 76 E2E expected diff patches updated to reflect the new renderStatus field in Kptfile output

@netlify
Copy link

netlify bot commented Mar 19, 2026

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 13ed78f
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/69bc535e86ad3c0007d37837
😎 Deploy Preview https://deploy-preview-4437--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@aravindtga aravindtga force-pushed the add_render_status_details_on_kptfile branch 3 times, most recently from e9f6347 to 3c93572 Compare March 19, 2026 19:28
Signed-off-by: aravind.est <aravindhan.a@est.tech>
@aravindtga aravindtga force-pushed the add_render_status_details_on_kptfile branch from 3c93572 to 13ed78f Compare March 19, 2026 19:49
@aravindtga aravindtga marked this pull request as ready for review March 19, 2026 20:04
Copilot AI review requested due to automatic review settings March 19, 2026 20:04
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. area/fn-runtime KRM function runtime enhancement New feature or request labels Mar 19, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the Kptfile v1 API types.
  • Track and persist per-step execution details during render, and write them into the root Kptfile for 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.

Comment on lines 746 to 750
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
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +647 to +660
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")
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@aravindtga aravindtga marked this pull request as draft March 19, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/fn-runtime KRM function runtime enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More intuitive RenderStatus schema

2 participants