Skip to content

Commit 5a09a30

Browse files
authored
Documentation: Add porch.kpt.dev/push-on-render-failure annotation behavior (kptdev#483)
* Added documentation for push-on-render-failure annotation Signed-off-by: aravind.est <aravindhan.a@est.tech> * Fix copilot review comments. Signed-off-by: aravind.est <aravindhan.a@est.tech> * Address review comments - 2 Signed-off-by: aravind.est <aravindhan.a@est.tech> --------- Signed-off-by: aravind.est <aravindhan.a@est.tech>
1 parent 1adec86 commit 5a09a30

8 files changed

Lines changed: 79 additions & 13 deletions

File tree

docs/content/en/docs/11_glossary/_index.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,19 @@ An executable that takes Kubernetes resources as input and produces Kubernetes r
229229

230230
### Rendering
231231

232-
The process of executing KRM functions defined in a package's Kptfile pipeline. Rendering occurs automatically when Draft packages are modified (via push operations). Function results are stored in the PackageRevision's `status.renderStatus` field.
232+
The process of executing KRM functions defined in a package's Kptfile pipeline. Rendering occurs automatically when Draft packages are modified (via push operations). Function results are stored in the PackageRevisionResources API resource's `status.renderStatus` field.
233233

234-
*See also*: [KRM Function](#krm-function), [Function Runner](#function-runner)
234+
By default, render failures prevent resources from being persisted. The `porch.kpt.dev/push-on-render-failure` annotation can override this behavior to save work-in-progress packages even when rendering fails.
235+
236+
*See also*: [KRM Function](#krm-function), [Function Runner](#function-runner), [Push on Render Failure](#push-on-render-failure)
237+
238+
### Push on Render Failure
239+
240+
An annotation (`porch.kpt.dev/push-on-render-failure: "true"`) that enables persisting Draft PackageRevision resources even when the kpt function render pipeline fails during resource updates. This allows saving work-in-progress packages during iterative development when the pipeline isn't fully functional yet. It does not apply to package creation operations (clone, init, edit, copy).
241+
242+
The behavior of partially-rendered resources can be further controlled via Kptfile annotations (see [kpt documentation](https://kpt.dev/book/04-using-functions/#debugging-render-failures)).
243+
244+
*See also*: [Rendering](#rendering), [Draft](#draft)
235245

236246
### Task
237247

docs/content/en/docs/2_concepts/functions.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ The `renderStatus` field contains:
7979
- Per-function results including exit codes and validation messages
8080
- Error details if function execution failed
8181

82-
Validation failures prevent Draft package revisions from being created and PackageRevisionResources from being updated.
82+
{{< alert title="Note" color="primary" >}}
83+
By default, render failures (including validation failures) prevent Draft package revisions from being created and PackageRevisionResources from
84+
being updated. However, when **updating resources on an existing Draft** (e.g. via `porchctl rpkg push`),
85+
adding the `porch.kpt.dev/push-on-render-failure: "true"` annotation **to the PackageRevision** allows persisting resources even when rendering fails,
86+
enabling iterative development on incomplete packages.
87+
{{< /alert >}}
88+
8389
8490
## Key Points
8591
@@ -88,4 +94,5 @@ Validation failures prevent Draft package revisions from being created and Packa
8894
- Functions automatically execute during package rendering on Draft package revisions
8995
- Function results are stored in `status.renderStatus` of the PackageRevisionResources view of a package revision
9096
- Published packages are immutable - functions don't re-execute after publication
91-
- Validation failures block Draft package creation and package revision resource updates
97+
- By default, render failures (including validation failures) block Draft package creation and package revision resource updates
98+
- When updating resources on an existing Draft (e.g., `porchctl rpkg push`), the `porch.kpt.dev/push-on-render-failure: "true"` annotation allows persisting resources despite render failures

docs/content/en/docs/4_tutorials_and_how-tos/working_with_package_revisions/_index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ Common issues when working with PackageRevisions and their solutions:
168168
- Check function image availability and version
169169
- Verify function configuration in Kptfile
170170
- Review function logs in Porch server output during push operations
171+
- **To save work-in-progress despite failures**: Add `porch.kpt.dev/push-on-render-failure: "true"` annotation to the PackageRevision
172+
```bash
173+
kubectl annotate packagerevision <name> porch.kpt.dev/push-on-render-failure=true
174+
```
175+
- The behavior of partially-rendered resources can be further controlled via Kptfile annotations (see [kpt documentation](https://kpt.dev/book/04-using-functions/#debugging-render-failures))
171176

172177
---
173178

docs/content/en/docs/5_architecture_and_components/controllers/interactions.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ Fetch PackageRevisionResources
298298
- Porch automatically executes render after resource update
299299
- Runs function pipeline from Kptfile
300300
- Returns RenderStatus with function results
301-
- Errors don't prevent draft closure (status indicates failure)
301+
- **Render failure handling**:
302+
- Default: Errors prevent draft closure (no resources persisted)
303+
- With `porch.kpt.dev/push-on-render-failure: "true"`: Draft closed even on failure (resources persisted)
304+
- Error always returned regardless of persistence
302305

303306
### Deletion Handling
304307

docs/content/en/docs/5_architecture_and_components/engine/functionality/draft-commit-orchestration.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,13 @@ UpdatePackageResources Request
359359
360360
Execute Render
361361
362-
Error? ──Yes──> Return Error + RenderStatus
363-
364-
No
362+
Error? ──Yes──> Check `porch.kpt.dev/push-on-render-failure` annotation
363+
│ ↓
364+
No "true"? ──Yes──> Close Draft + Return Error
365+
↓ │
366+
│ No
367+
│ ↓
368+
│ Return Error (no push)
365369
366370
Close Draft (no lifecycle change)
367371
@@ -376,7 +380,11 @@ UpdatePackageResources Request
376380
5. **Update to draft** (opens existing revision)
377381
6. **Apply resource mutations** through task handler
378382
7. **Execute render** (run function pipeline)
379-
8. **Close draft** without lifecycle change
383+
8. **Check render result**:
384+
- Success: Close draft and return
385+
- Failure: Check `porch.kpt.dev/push-on-render-failure` annotation
386+
- If `"true"`: Close draft (persist resources) and return error
387+
- Otherwise: Return error without persisting
380388
9. **Return** updated package revision and render status
381389

382390
### Resource Mutation
@@ -403,7 +411,40 @@ TaskHandler.DoPRResourceMutations
403411
- Runs configured KRM function pipeline
404412
- Functions can validate, transform, generate resources
405413
- Results returned in RenderStatus
406-
- Errors don't prevent draft closure (render status indicates failure)
414+
- **Render failure handling**:
415+
- Default behavior: Render errors prevent draft closure (no resources persisted)
416+
- With `porch.kpt.dev/push-on-render-failure: "true"` annotation: Draft is closed even on render failure
417+
- The behavior of partially-rendered resources can be further controlled via Kptfile annotations (see [kpt documentation](https://kpt.dev/book/04-using-functions/#debugging-render-failures))
418+
- Error is always returned to caller regardless of persistence behavior
419+
420+
### Persisting Resources on Render Failure
421+
422+
The `porch.kpt.dev/push-on-render-failure` annotation enables saving work-in-progress packages even when the kpt function render pipeline fails:
423+
424+
**Annotation behavior:**
425+
426+
| PackageRevision Annotation | Kptfile Annotation | Render Result | Behavior |
427+
|----------------------------|-------------------|---------------|----------|
428+
| Not set | Not set | Success | Push rendered resources |
429+
| Not set | Not set | Failure | No push, error returned |
430+
| `"true"` | Not set | Success | Push rendered resources |
431+
| `"true"` | Not set | Failure | Push unrendered resources, error returned |
432+
| `"true"` | `"true"` | Failure | Push partially-rendered resources, error returned |
433+
| `"false"` | Not set | Failure | No push, error returned |
434+
| Not set | `"true"` | Failure | No push, error returned (kpt may have produced partial output internally) |
435+
436+
**How to use:**
437+
```bash
438+
# Add annotation to PackageRevision
439+
kubectl annotate packagerevision <name> porch.kpt.dev/push-on-render-failure=true
440+
```
441+
442+
**Important notes:**
443+
- Only applies to Draft PackageRevisions during resource updates (via `UpdatePackageResources`)
444+
- Does not apply to package creation operations (init, clone, edit, copy)
445+
- Error is always returned even when resources are persisted
446+
- The behavior of partially-rendered resources can be further controlled via Kptfile annotations (see [kpt documentation](https://kpt.dev/book/04-using-functions/#debugging-render-failures))
447+
- In rare cases (e.g., internal errors during resource persistence), push may be prevented regardless of the annotation
407448

408449
## Rollback Mechanism
409450

docs/content/en/docs/6_configuration_and_deployments/configurations/opentelemetry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Porch supports OpenTelemetry observability through the [autoexport package](http
1111

1212
All Porch components (porch-server, porch-controllers, function-runner, and wrapper-server) support OpenTelemetry configuration through standardized environment variables as defined by the [OpenTelemetry specification](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/).
1313

14-
{{% alert title="Note" color="info" %}}
14+
{{% alert title="Note" color="primary" %}}
1515
**Current Implementation Status**: Porch currently implements metrics and traces export. Logs export is not supported.
1616
{{% /alert %}}
1717

docs/content/en/docs/6_configuration_and_deployments/configurations/repository-sync.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 1
55
description: "Configure repository synchronization for Porch Repositories"
66
---
77

8-
{{% alert title="Documentation Location" color="info" %}}
8+
{{% alert title="Documentation Location" color="primary" %}}
99
This documentation is currently located in the system configuration section but should be moved to a more logical location as it's about configuring individual Repository resources, not system-wide settings. This may be relocated in future documentation updates.
1010
{{% /alert %}}
1111

docs/content/en/docs/6_configuration_and_deployments/deployments/catalog-deployment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ These features can be configured **after** deployment:
3030

3131
- [Git Authentication]({{% relref "../configurations/components/porch-server-config/git-authentication" %}}) - Configure Porch Server authentication for private Git repositories
3232

33-
{{% alert title="Note" color="info" %}}
33+
{{% alert title="Note" color="primary" %}}
3434
[Repository Sync]({{% relref "../configurations/repository-sync" %}}) configuration is currently located in the system configuration section but should be moved to a more logical location as it's about configuring individual Repository resources, not system-wide settings.
3535
{{% /alert %}}
3636

0 commit comments

Comments
 (0)