Add implementation of 'porch.kpt.dev/push-on-render-failure' for clone and upgrade - #1126
Add implementation of 'porch.kpt.dev/push-on-render-failure' for clone and upgrade#1126liamfallon wants to merge 9 commits into
Conversation
✅ Deploy Preview for kpt-porch ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Implements support for the porch.kpt.dev/push-on-render-failure annotation during subpackage clone/upgrade by propagating render status through the mutation path and adding e2e coverage for the persisted-on-render-failure behavior.
Changes:
- Extend
DoPRMutations/UpdatePackageRevisionAPIs to return*RenderStatusalongside errors. - Refactor generic task handling to centralize render+persist logic and return render status.
- Add e2e tests covering subpackage clone/upgrade behavior with/without push-on-render-failure under render failures.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
test/e2e/api/rpkg_subpkg_test.go |
Adds e2e coverage for subpackage clone/upgrade when render fails, with and without the annotation. |
pkg/task/taskhandler.go |
Updates task handler interface to return render status from PR mutations. |
pkg/task/generictaskhandler.go |
Refactors/render-path changes to return render status and reuse a shared renderResources helper. |
pkg/task/generictaskhandler_test.go |
Adjusts unit tests to the new DoPRMutations signature. |
pkg/engine/engine.go |
Plumbs render status return through UpdatePackageRevision and uses mutation error handling logic. |
pkg/engine/engine_test.go |
Updates mock task handler for new return type. |
pkg/registry/porch/packagecommon.go |
Attempts to attach render status to resources after update. |
pkg/registry/porch/*_test.go |
Updates mocks for the new UpdatePackageRevision return signature. |
Files not reviewed (1)
- test/mockery/mocks/porch/pkg/engine/mock_CaDEngine.go: Generated file
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.
Files not reviewed (1)
- test/mockery/mocks/porch/pkg/engine/mock_CaDEngine.go: Generated file
Comments suppressed due to low confidence (3)
pkg/engine/engine.go:407
- UpdatePackageRevision computes
renderStatusfrom DoPRMutations, but the success return drops it (return repoPkgRev, nil, nil). This makes the new(repo, *RenderStatus, error)signature largely useless and prevents callers from surfacing/persisting render details (especially important for push-on-render-failure).
sent := cad.watcherManager.NotifyPackageRevisionChange(watch.Modified, repoPkgRev)
klog.Infof("engine: sent %d for updated PackageRevision %s/%s", sent, repoPkgRev.KubeObjectNamespace(), repoPkgRev.KubeObjectName())
return repoPkgRev, nil, nil
pkg/registry/porch/packagecommon.go:409
- This tries to persist
resources.Status.RenderStatus, but then calls UpdatePackageResourcesWithoutRender which only writesSpec.Resources(it discards Status entirely). As a result, the render status update is not persisted and won’t be observable later.
resources.Status.RenderStatus = *renderStatus
rev, err = r.cad.UpdatePackageResourcesWithoutRender(ctx, &repositoryObj, oldRepoPkgRev, resources, resources)
if err != nil {
test/e2e/api/e2e_test.go:21
oswas removed from imports when the E2E gating was commented out. If the gating is restored,osneeds to be imported to keep the file compiling.
import (
"testing"
suiteutils "github.com/kptdev/porch/test/e2e/suiteutils"
"github.com/stretchr/testify/suite"
7ba0272 to
4e5f092
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Files not reviewed (1)
- test/mockery/mocks/porch/pkg/engine/mock_CaDEngine.go: Generated file
Comments suppressed due to low confidence (4)
pkg/engine/engine.go:407
UpdatePackageRevisioncomputesrenderStatus(fromDoPRMutations) but the success return always drops it (return repoPkgRev, nil, nil). This makes the new(PackageRevision, *RenderStatus, error)signature misleading and prevents callers (e.g.packagecommon.updatePackageRevision) from observing render results on successful updates.
sent := cad.watcherManager.NotifyPackageRevisionChange(watch.Modified, repoPkgRev)
klog.Infof("engine: sent %d for updated PackageRevision %s/%s", sent, repoPkgRev.KubeObjectNamespace(), repoPkgRev.KubeObjectName())
return repoPkgRev, nil, nil
pkg/registry/porch/packagecommon.go:408
- This attempts to persist
resources.Status.RenderStatus, butUpdatePackageResourcesWithoutRenderonly writesnewRes.Spec.Resourcesand constructs a new object without copyingStatus. As a result, theRenderStatusassignment here is effectively discarded, and may also fail if the PR lifecycle is no longer Draft (the method enforces Draft). A dedicated status-persist path (or extendingUpdatePackageResourcesWithoutRenderto persist status) is needed ifRenderStatusmust be retained across reads.
resources.Status.RenderStatus = *renderStatus
rev, err = r.cad.UpdatePackageResourcesWithoutRender(ctx, &repositoryObj, oldRepoPkgRev, resources, resources)
test/e2e/api/rpkg_subpkg_test.go:700
- Spelling: "rander" → "render" in the test description comment.
// TestSubpackageCloneRenderFailureWithPush verifies that when a subpackage clone
// to a parent PR where the parent PR has rander failures and HAS the
// push-on-render-failure annotation, the update does not return an error and the
// subpackage resources are persisted. The render pipeline on the PR should always fail.
test/e2e/api/rpkg_subpkg_test.go:786
- Spelling: "rander" → "render" in the test description comment.
// TestSubpackageUpgradeRenderFailureWithPush verifies that when a subpackage upgrade
// to a parent PR where the parent PR has rander failures and HAS the
// push-on-render-failure annotation, the update does not return an error and the
// subpackage resources are persisted. The render pipeline on the PR should always fail.
183e731 to
f34edc9
Compare
…ackages Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
f34edc9 to
af77188
Compare
|



Add implementation of
porch.kpt.dev/push-on-render-failurefor subpackage clone and upgradeDescription
porch.kpt.dev/push-on-render-failureannotation on a PRNote that there was no need to support the
porch.kpt.dev/push-on-render-failureannotation on clones and upgrades until now becauseThe implementation here will now also respect the
porch.kpt.dev/push-on-render-failureif, for example, a non subpackage clone or upgrade fails due to connectivity issues etc.Related Issue(s)
Type of Change
Checklist
AI Disclosure
I used Amazon Q to generate the unit tests and E2E tests for this PR. I inspected and ran the tests afterwards to ensure they work and are correct.