Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement CEL runtime cost budget in controller #191

Open
a-hilaly opened this issue Jan 9, 2025 · 0 comments
Open

implement CEL runtime cost budget in controller #191

a-hilaly opened this issue Jan 9, 2025 · 0 comments

Comments

@a-hilaly
Copy link
Member

a-hilaly commented Jan 9, 2025

Feature Description

Currently kro doesn't enforce any limits on CEL expression evaluation costs. We need to implement cost budgeting similar to Kubernetes API server to prevent resource exhaustion from complex expressions. The controller should enforce both per call and total runtime budgets.

Example constants, inspired from https://github.com/kubernetes/apiserver/blob/2241ea00526fdd746871375dfca871627f6a511a/pkg/apis/cel/config.go#L1

const (
    // PerCallLimit specifies the cost limit per individual CEL expression evaluation
    // This gives roughly 0.1 second of execution time per expression evaluation
    PerCallLimit = 1000000

    // RuntimeCELCostBudget is the total cost budget allowed during a single 
    // ResourceGroup reconciliation cycle. This includes all expression evaluations
    // across all resources defined in the ResourceGroup. The budget gives roughly
    // 1 second of total execution time before being exceeded.
    RuntimeCELCostBudget = 10000000

    // CheckFrequency configures the number of iterations within a comprehension to evaluate
    // before checking whether the function evaluation has been interrupted
    CheckFrequency = 100
)

Example error when budget is exceeded:

apiVersion: kro.run/v1alpha1
kind: ResourceGroup
metadata:
  name: my-application
status:
  conditions:
    - type: Ready
      status: "False"
      reason: CELBudgetExceeded
      message: "Total CEL cost 12M exceeded budget of 10M"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant