Repository navigation
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #156 +/- ##
==========================================
- Coverage 92.58% 92.54% -0.04%
==========================================
Files 115 115
Lines 6929 6937 +8
==========================================
+ Hits 6415 6420 +5
- Misses 514 517 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
7dac286 to
acf7d76
Compare
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="cel/engine.go">
<violation number="1" location="cel/engine.go:82">
P3: This says every compiled program is cached, but typed-environment programs are recompiled instead. Qualify the statement so readers do not infer that a `CostLimit` change has the same cached-program behavior for every environment.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| // program, which is cached, so a host that changes it does so at startup, before | ||
| // any expression is compiled. |
There was a problem hiding this comment.
P3: This says every compiled program is cached, but typed-environment programs are recompiled instead. Qualify the statement so readers do not infer that a CostLimit change has the same cached-program behavior for every environment.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At cel/engine.go, line 82:
<comment>This says every compiled program is cached, but typed-environment programs are recompiled instead. Qualify the statement so readers do not infer that a `CostLimit` change has the same cached-program behavior for every environment.</comment>
<file context>
@@ -78,8 +78,9 @@ const (
-// sets for CRD validation rules. It is process-wide and read when an expression
-// is compiled, so a host that changes it does so before the first evaluation.
+// sets for CRD validation rules. It is process-wide and fixed into each compiled
+// program, which is cached, so a host that changes it does so at startup, before
+// any expression is compiled.
var CostLimit uint64 = 1_000_000
</file context>
| // program, which is cached, so a host that changes it does so at startup, before | |
| // any expression is compiled. | |
| // program. Programs for the dynamic environment are cached; typed-environment | |
| // programs are not, so hosts should set it at startup, before any expression | |
| // is compiled. |
…s context An expression ran to completion however long it took, ignoring every deadline, so a costly one held a CPU in the webhook or a controller until it finished. Programs are compiled with a runtime cost limit, CostLimit (1,000,000, the per-expression limit Kubernetes sets for CRD validation rules), and an interrupt check, and Plan.Eval runs under its caller's context. An evaluation past the limit fails with "expression exceeds the evaluation cost limit"; one whose context is done fails wrapping the context's error. Cost tracking adds about a microsecond or a few to an evaluation in the package's benchmarks. Signed-off-by: Brian Kane <briankane1@gmail.com>
acf7d76 to
c361028
Compare
Description of your changes
Bounds a CEL expression's evaluation. Found in the v1.12 release testing.
An expression now stops at a cost limit of 1,000,000 and when its caller's context is cancelled, instead of
running for as long as it takes. kubevela/kubevela picks this up for the 1.12 release.
How has this code been tested
Unit tests for the cost limit and for cancellation, red before the fix and green after; the package suites pass
(envtest 1.37.0).
Summary by cubic
Bounds CEL expression evaluation so expensive expressions stop at a cost limit and respect their caller's context instead of running to completion. Evaluation now fails with "expression exceeds the evaluation cost limit" when it passes 1,000,000 (the per-expression limit Kubernetes sets for CRD validation rules), and
Plan.Evalaborts early when its context is cancelled. Adds tests covering the cost limit and cancellation for previously unbounded evaluations.Written for commit c361028. Summary will update on new commits.