nephio-project / nephio

Nephio is a Kubernetes-based automation platform for deploying and managing highly distributed, interconnected workloads such as 5G Network Functions, and the underlying infrastructure on which those workloads depend.
Apache License 2.0
93 stars 52 forks source link

function runtimes in porch does not return structured result when rendering a package #699

Open liamfallon opened 3 months ago

liamfallon commented 3 months ago

Original issue URL: https://github.com/kptdev/kpt/issues/3628 Original issue user: https://github.com/droot Original issue created at: 2022-10-18T23:25:06Z Original issue last updated at: 2023-01-31T19:55:36Z Original issue body: Porch has two runtimes (builtin and podevaluator). Both the runtimes doesn't return structuredResult.

I am seeing following error in porch during testing a package with kubeval function:

fn.render: pkg .:
    pkg.render:
    pipeline.run: func eval "gcr.io/kpt-fn/kubeval:v0.3.0" failed: rpc error: code = Unknown desc = unable to evaluate gcr.io/kpt-fn/kubeval:v0.3.0 with pod evaluator: rpc error: code = Internal desc = failed to evaluate function "gcr.io/kpt-fn/kubeval:v0.3.0" with structured results: [error] apps/v1/Deployment/example/default spec.replicas: Invalid type. Expected: [integer,null], given: string and stderr: 

It clearly has the correct validation errors but somehow the function runtime machinery (with render library) is not returning this validation errors in structured error format.

Original issue comments: Comment user: https://github.com/droot Comment created at: 2022-10-18T23:26:52Z Comment last updated at: 2022-10-18T23:26:52Z Comment body: /cc @ChristopherFry Making some progress in surfacing errors and results now. The above error is returned as part of the packagerevisionresources API (ignore the formatting the error message itself :))

Comment user: https://github.com/yuwenma Comment created at: 2023-01-13T13:58:47Z Comment last updated at: 2023-01-13T13:58:47Z Comment body: @droot I feel like this can be a good "good first issue" candidate. Please remove the label if you prefer to take it.

Comment user: https://github.com/droot Comment created at: 2023-01-31T19:55:36Z Comment last updated at: 2023-01-31T19:55:36Z Comment body: > @droot I feel like this can be a good "good first issue" candidate. Please remove the label if you prefer to take it.

Sg. Unassigned so that someone can pick this up.

kispaljr commented 2 weeks ago

The original statement is only partly true. Structured rendering results are returned in the status.renderStatus field of the PackageRevisionResources object returned by an Update operation. (see e.g. here)

However, I would expect to see the same rendering results when I simply query PackageRevisionResources objects. But in this case status.renderStatus will always be empty, similar to this:

status:
  renderStatus:
    error: ""
    result:
      exitCode: 0
      metadata:
        creationTimestamp: null

even if the package has a non-empty pipeline.

To be able to query the status of the last kpt package rendering, the renderStatus value should be persisted, IMHO in the (git/oci) repository. One option would be to write it into the Kptfile's status field, and handle it similarly to how we handle PackageRevision's status.conditions.

kispaljr commented 2 weeks ago

Related to #730 and https://github.com/nephio-project/porch/pull/75