You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add context_template to workflow approval nodes (#578)
* Add context_template to workflow approval nodes for approver visibility
Approval nodes can now include a Jinja2 context_template that gets rendered
with upstream set_stats artifacts when the approval is created. The rendered
result is stored as context_message on the WorkflowApproval instance and
displayed to the approver in the UI detail view and in the pending approval
notification. This lets workflow authors surface relevant context (dry-run
output, planned changes, terraform plan summaries) directly to the person
who needs to approve, without them having to go find the previous job output.
* Harden approval context_template rendering against resource exhaustion
The Jinja2 sandbox blocks attribute escapes but not templates that burn
CPU or memory, so rendering now happens in a short lived forked process
with RLIMIT_CPU and RLIMIT_AS applied, and the task manager abandons and
kills it after a hard timeout instead of blocking the scheduler loop.
The rendered output is capped at 64KB.
Also render with the artifacts passed as a context dict instead of
**kwargs, so set_stats keys that are not valid identifiers cannot raise
TypeError, and allow static templates to render when a node has no
upstream artifacts. Any child process failure is logged and the approval
is simply created without a context message.
Adds functional tests covering rendering, static templates, weird
artifact keys, template errors, the render timeout, the CPU and memory
limits and output truncation.
* Keep context_message out of the workflow approval list serializer
The rendered context can be large, so only the detail endpoint returns
it. The UI detail view already reads it from the detail endpoint. Adds
an API test asserting the field shows up on detail and not on the list.
0 commit comments