Merge pull request #122518 from cici37/celEnv29
Update env version, add cost for previous added func, add tests, etc. Kubernetes-commit: 31197eba75040cb0b88f488caf18a4c87182abed
This commit is contained in:
commit
888034e53f
4
go.mod
4
go.mod
|
|
@ -45,7 +45,7 @@ require (
|
|||
k8s.io/api v0.0.0-20240118211853-d5724e467262
|
||||
k8s.io/apimachinery v0.0.0-20240118211638-f14778da5523
|
||||
k8s.io/client-go v0.0.0-20240122172058-657d7be98b25
|
||||
k8s.io/component-base v0.0.0-20240118212833-be1cabd1bd81
|
||||
k8s.io/component-base v0.0.0-20240123212339-5f9f8131aa48
|
||||
k8s.io/klog/v2 v2.120.1
|
||||
k8s.io/kms v0.0.0-20231220174908-0e979309a09f
|
||||
k8s.io/kube-openapi v0.0.0-20231113174909-778a5567bc1e
|
||||
|
|
@ -128,6 +128,6 @@ replace (
|
|||
k8s.io/api => k8s.io/api v0.0.0-20240118211853-d5724e467262
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20240118211638-f14778da5523
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20240122172058-657d7be98b25
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20240118212833-be1cabd1bd81
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20240123212339-5f9f8131aa48
|
||||
k8s.io/kms => k8s.io/kms v0.0.0-20231220174908-0e979309a09f
|
||||
)
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -391,8 +391,8 @@ k8s.io/apimachinery v0.0.0-20240118211638-f14778da5523 h1:1iJCbQAZv58v4zxd0ECIIM
|
|||
k8s.io/apimachinery v0.0.0-20240118211638-f14778da5523/go.mod h1:Oh3ZrffM1/I8O/43oAA+aoOYgSregIXHxcWJB9ZRfQ8=
|
||||
k8s.io/client-go v0.0.0-20240122172058-657d7be98b25 h1:iBiouUazhDUHxrqDywgcbmARvao6UwVu+nSbIrIRh4k=
|
||||
k8s.io/client-go v0.0.0-20240122172058-657d7be98b25/go.mod h1:WuuT9L6+pj4rHmL2pb22xnOdtSvjiEcpB18g9Fuk0js=
|
||||
k8s.io/component-base v0.0.0-20240118212833-be1cabd1bd81 h1:Ks1+11dEZI6KLON5tZqbVNkF8+m9QPx395I8Ay50a+U=
|
||||
k8s.io/component-base v0.0.0-20240118212833-be1cabd1bd81/go.mod h1:VQmPwZSYOM8FYEnNvSHNO/JiRnejhPJqWOPLG4/BWfU=
|
||||
k8s.io/component-base v0.0.0-20240123212339-5f9f8131aa48 h1:3HvTUZ0ry5c0P15P+glBxBj+eh8Uv2ijNvjEORH+oOQ=
|
||||
k8s.io/component-base v0.0.0-20240123212339-5f9f8131aa48/go.mod h1:ANnr9YwsqK1XgjzXj9fGHEMDOp0QddDkKgQLLBPZ7Kg=
|
||||
k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
|
||||
k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
|
||||
k8s.io/kms v0.0.0-20231220174908-0e979309a09f h1:rfX7Jxf6fLy/4qh6tWv+hwn7z25oYr6yZkcVVSSZqnE=
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import (
|
|||
// desirable because it means that CEL expressions are portable across a wider range
|
||||
// of Kubernetes versions.
|
||||
func DefaultCompatibilityVersion() *version.Version {
|
||||
return version.MajorMinor(1, 28)
|
||||
return version.MajorMinor(1, 29)
|
||||
}
|
||||
|
||||
var baseOpts = []VersionedOptions{
|
||||
|
|
|
|||
|
|
@ -147,6 +147,14 @@ func (l *CostEstimator) CallCost(function, overloadId string, args []ref.Val, re
|
|||
|
||||
return &cost
|
||||
}
|
||||
case "quantity", "isQuantity":
|
||||
if len(args) >= 1 {
|
||||
cost := uint64(math.Ceil(float64(actualSize(args[0])) * common.StringTraversalCostFactor))
|
||||
return &cost
|
||||
}
|
||||
case "sign", "asInteger", "isInteger", "asApproximateFloat", "isGreaterThan", "isLessThan", "compareTo", "add", "sub":
|
||||
cost := uint64(1)
|
||||
return &cost
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -360,6 +368,13 @@ func (l *CostEstimator) EstimateCallCost(function, overloadId string, target *ch
|
|||
|
||||
return &checker.CallEstimate{CostEstimate: ipCompCost}
|
||||
}
|
||||
case "quantity", "isQuantity":
|
||||
if target != nil {
|
||||
sz := l.sizeEstimate(args[0])
|
||||
return &checker.CallEstimate{CostEstimate: sz.MultiplyByCostFactor(common.StringTraversalCostFactor)}
|
||||
}
|
||||
case "sign", "asInteger", "isInteger", "asApproximateFloat", "isGreaterThan", "isLessThan", "compareTo", "add", "sub":
|
||||
return &checker.CallEstimate{CostEstimate: checker.CostEstimate{Min: 1, Max: 1}}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue