Skip to content

Commit 0ebef0c

Browse files
committed
DRA: add CEL cost limit
1 parent 55d986c commit 0ebef0c

File tree

1 file changed

+32
-16
lines changed
  • keps/sig-node/4381-dra-structured-parameters

1 file changed

+32
-16
lines changed

keps/sig-node/4381-dra-structured-parameters/README.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,18 +1539,34 @@ type CELDeviceSelector struct {
15391539
//
15401540
// cel.bind(dra, device.attributes["dra.example.com"], dra.someBool && dra.anotherBool)
15411541
//
1542+
// The length of the expression must be smaller or equal to 10 Ki. The
1543+
// cost of evaluating it is also limited based on the estimated number
1544+
// of logical steps. Validation against those limits happens only when
1545+
// setting an expression for the first time or when changing
1546+
// it. Therefore it is possible to change these limits without
1547+
// affecting stored expressions. Those remain valid.
1548+
//
15421549
// +required
15431550
Expression string
15441551
}
1545-
```
1546-
1547-
<<[UNRESOLVED pohly]>>
15481552

1549-
Describe how CEL cost limits work.
1553+
// CELSelectorExpressionMaxCost specifies the cost limit for a single CEL selector
1554+
// evaluation.
1555+
//
1556+
// There is no overall budget for selecting a device, so the actual time
1557+
// required for that is proportional to the number of CEL selectors and how
1558+
// often they need to be evaluated, which can vary depending on several factors
1559+
// (number of devices, cluster utilization, additional constraints).
1560+
//
1561+
// According to
1562+
// https://github.com/kubernetes/kubernetes/blob/4aeaf1e99e82da8334c0d6dddd848a194cd44b4f/staging/src/k8s.io/apiserver/pkg/apis/cel/config.go#L20-L22,
1563+
// this gives roughly 0.1 second for each expression evaluation.
1564+
// However, this depends on how fast the machine is.
1565+
const CELSelectorExpressionMaxCost = 1000000
15501566

1551-
<<[/UNRESOLVED]>>
1567+
// CELSelectorExpressionMaxLength is the maximum length of a CEL selector expression string.
1568+
const CELSelectorExpressionMaxLength = 10 * 1024
15521569

1553-
```yaml
15541570
// DeviceConstraint must have exactly one field set besides Requests.
15551571
type DeviceConstraint struct {
15561572
// Requests is a list of the one or more requests in this claim which
@@ -1843,16 +1859,16 @@ type DeviceRequestAllocationResult struct {
18431859
// +required
18441860
Device string
18451861

1846-
// AdminAccess is a copy of the AdminAccess value in the
1847-
// request which caused this device to be allocated.
1848-
//
1849-
// New allocations are required to have this set. Old allocations made
1850-
// by Kubernetes 1.31 do not have it yet. Clients which want to
1851-
// support Kubernetes 1.31 need to look up the request and retrieve
1852-
// the value from there if this field is not set.
1853-
//
1854-
// +required
1855-
AdminAccess *bool
1862+
// AdminAccess is a copy of the AdminAccess value in the
1863+
// request which caused this device to be allocated.
1864+
//
1865+
// New allocations are required to have this set. Old allocations made
1866+
// by Kubernetes 1.31 do not have it yet. Clients which want to
1867+
// support Kubernetes 1.31 need to look up the request and retrieve
1868+
// the value from there if this field is not set.
1869+
//
1870+
// +required
1871+
AdminAccess *bool
18561872
}
18571873

18581874
// DeviceAllocationConfiguration gets embedded in an AllocationResult.

0 commit comments

Comments
 (0)